< Summary

Information
Class: LGDXRobotCloud.API.Areas.Automation.Controllers.ProgressesController
Assembly: LGDXRobotCloud.API
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Areas/Automation/Controllers/ProgressesController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 37
Coverable lines: 37
Total lines: 92
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)0%2040%
GetProgresses()0%620%
SearchProgresses()100%210%
GetProgress()100%210%
CreateProgress()100%210%
UpdateProgress()100%210%
TestDeleteProgress()100%210%
DeleteProgress()100%210%

File(s)

/builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Areas/Automation/Controllers/ProgressesController.cs

#LineLine coverage
 1using LGDXRobotCloud.API.Authorisation;
 2using LGDXRobotCloud.API.Configurations;
 3using LGDXRobotCloud.API.Services.Automation;
 4using LGDXRobotCloud.Data.Models.Business.Automation;
 5using LGDXRobotCloud.Data.Models.DTOs.V1.Commands;
 6using LGDXRobotCloud.Data.Models.DTOs.V1.Responses;
 7using Microsoft.AspNetCore.Authentication.JwtBearer;
 8using Microsoft.AspNetCore.Authorization;
 9using Microsoft.AspNetCore.Mvc;
 10using Microsoft.Extensions.Options;
 11using System.Text.Json;
 12
 13namespace LGDXRobotCloud.API.Areas.Automation.Controllers;
 14
 15[ApiController]
 16[Area("Automation")]
 17[Route("[area]/[controller]")]
 18[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
 19[ValidateLgdxUserAccess]
 020public sealed class ProgressesController(
 021    IOptionsSnapshot<LgdxRobotCloudConfiguration> lgdxRobotCloudConfiguration,
 022    IProgressService progressService
 023  ) : ControllerBase
 24{
 025  private readonly LgdxRobotCloudConfiguration _lgdxRobotCloudConfiguration = lgdxRobotCloudConfiguration.Value ?? throw
 026  private readonly IProgressService _progressService = progressService ?? throw new ArgumentNullException(nameof(progres
 27
 28  [HttpGet("")]
 29  [ProducesResponseType(typeof(IEnumerable<ProgressDto>), StatusCodes.Status200OK)]
 30  public async Task<ActionResult<IEnumerable<ProgressDto>>> GetProgresses(string? name, int pageNumber = 1, int pageSize
 031  {
 032    pageSize = (pageSize > _lgdxRobotCloudConfiguration.ApiMaxPageSize) ? _lgdxRobotCloudConfiguration.ApiMaxPageSize : 
 033    var (progresses, PaginationHelper) = await _progressService.GetProgressesAsync(name, pageNumber, pageSize, system);
 034    Response.Headers.Append("X-Pagination", JsonSerializer.Serialize(PaginationHelper));
 035    return Ok(progresses.ToDto());
 036  }
 37
 38  [HttpGet("Search")]
 39  [ProducesResponseType(typeof(IEnumerable<ProgressSearchDto>), StatusCodes.Status200OK)]
 40  public async Task<ActionResult<IEnumerable<ProgressSearchDto>>> SearchProgresses(string? name, bool reserved = false)
 041  {
 042    var progresses = await _progressService.SearchProgressesAsync(name, reserved);
 043    return Ok(progresses.ToDto());
 044  }
 45
 46  [HttpGet("{id}", Name = "GetProgress")]
 47  [ProducesResponseType(typeof(ProgressDto), StatusCodes.Status200OK)]
 48  [ProducesResponseType(StatusCodes.Status404NotFound)]
 49  public async Task<ActionResult<ProgressDto>> GetProgress(int id)
 050  {
 051    var progress = await _progressService.GetProgressAsync(id);
 052    return Ok(progress.ToDto());
 053  }
 54
 55  [HttpPost("")]
 56  [ProducesResponseType(typeof(ProgressDto), StatusCodes.Status201Created)]
 57  public async Task<ActionResult> CreateProgress(ProgressCreateDto progressCreateDto)
 058  {
 059    var progress = await _progressService.CreateProgressAsync(progressCreateDto.ToBusinessModel());
 060    return CreatedAtRoute(nameof(GetProgress), new { id = progress.Id }, progress.ToDto());
 061  }
 62
 63  [HttpPut("{id}")]
 64  [ProducesResponseType(StatusCodes.Status204NoContent)]
 65  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 66  [ProducesResponseType(StatusCodes.Status404NotFound)]
 67  public async Task<ActionResult> UpdateProgress(int id, ProgressUpdateDto progressUpdateDto)
 068  {
 069    await _progressService.UpdateProgressAsync(id, progressUpdateDto.ToBusinessModel());
 070    return NoContent();
 071  }
 72
 73  [HttpPost("{id}/TestDelete")]
 74  [ProducesResponseType(StatusCodes.Status200OK)]
 75  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 76  public async Task<ActionResult> TestDeleteProgress(int id)
 077  {
 078    await _progressService.TestDeleteProgressAsync(id);
 079    return Ok();
 080  }
 81
 82  [HttpDelete("{id}")]
 83  [ProducesResponseType(StatusCodes.Status204NoContent)]
 84  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 85  [ProducesResponseType(StatusCodes.Status404NotFound)]
 86  public async Task<ActionResult> DeleteProgress(int id)
 087  {
 088    await _progressService.TestDeleteProgressAsync(id);
 089    await _progressService.DeleteProgressAsync(id);
 090    return NoContent();
 091  }
 92}