< 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: 94
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 LGDXRobotCloud.Utilities.Constants;
 8using Microsoft.AspNetCore.Authentication.JwtBearer;
 9using Microsoft.AspNetCore.Authorization;
 10using Microsoft.AspNetCore.Mvc;
 11using Microsoft.Extensions.Options;
 12using System.Text.Json;
 13
 14namespace LGDXRobotCloud.API.Areas.Automation.Controllers;
 15
 16[ApiController]
 17[Area("Automation")]
 18[Route("[area]/[controller]")]
 19[Authorize(AuthenticationSchemes = LgdxRobotCloudAuthenticationSchemes.ApiKeyOrCertificationScheme)]
 20[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
 21[ValidateLgdxUserAccess]
 022public sealed class ProgressesController(
 023    IOptionsSnapshot<LgdxRobotCloudConfiguration> lgdxRobotCloudConfiguration,
 024    IProgressService progressService
 025  ) : ControllerBase
 26{
 027  private readonly LgdxRobotCloudConfiguration _lgdxRobotCloudConfiguration = lgdxRobotCloudConfiguration.Value ?? throw
 028  private readonly IProgressService _progressService = progressService ?? throw new ArgumentNullException(nameof(progres
 29
 30  [HttpGet("")]
 31  [ProducesResponseType(typeof(IEnumerable<ProgressDto>), StatusCodes.Status200OK)]
 32  public async Task<ActionResult<IEnumerable<ProgressDto>>> GetProgresses(string? name, int pageNumber = 1, int pageSize
 033  {
 034    pageSize = (pageSize > _lgdxRobotCloudConfiguration.ApiMaxPageSize) ? _lgdxRobotCloudConfiguration.ApiMaxPageSize : 
 035    var (progresses, PaginationHelper) = await _progressService.GetProgressesAsync(name, pageNumber, pageSize, system);
 036    Response.Headers.Append("X-Pagination", JsonSerializer.Serialize(PaginationHelper));
 037    return Ok(progresses.ToDto());
 038  }
 39
 40  [HttpGet("Search")]
 41  [ProducesResponseType(typeof(IEnumerable<ProgressSearchDto>), StatusCodes.Status200OK)]
 42  public async Task<ActionResult<IEnumerable<ProgressSearchDto>>> SearchProgresses(string? name, bool reserved = false)
 043  {
 044    var progresses = await _progressService.SearchProgressesAsync(name, reserved);
 045    return Ok(progresses.ToDto());
 046  }
 47
 48  [HttpGet("{id}", Name = "GetProgress")]
 49  [ProducesResponseType(typeof(ProgressDto), StatusCodes.Status200OK)]
 50  [ProducesResponseType(StatusCodes.Status404NotFound)]
 51  public async Task<ActionResult<ProgressDto>> GetProgress(int id)
 052  {
 053    var progress = await _progressService.GetProgressAsync(id);
 054    return Ok(progress.ToDto());
 055  }
 56
 57  [HttpPost("")]
 58  [ProducesResponseType(typeof(ProgressDto), StatusCodes.Status201Created)]
 59  public async Task<ActionResult> CreateProgress(ProgressCreateDto progressCreateDto)
 060  {
 061    var progress = await _progressService.CreateProgressAsync(progressCreateDto.ToBusinessModel());
 062    return CreatedAtRoute(nameof(GetProgress), new { id = progress.Id }, progress.ToDto());
 063  }
 64
 65  [HttpPut("{id}")]
 66  [ProducesResponseType(StatusCodes.Status204NoContent)]
 67  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 68  [ProducesResponseType(StatusCodes.Status404NotFound)]
 69  public async Task<ActionResult> UpdateProgress(int id, ProgressUpdateDto progressUpdateDto)
 070  {
 071    await _progressService.UpdateProgressAsync(id, progressUpdateDto.ToBusinessModel());
 072    return NoContent();
 073  }
 74
 75  [HttpPost("{id}/TestDelete")]
 76  [ProducesResponseType(StatusCodes.Status200OK)]
 77  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 78  public async Task<ActionResult> TestDeleteProgress(int id)
 079  {
 080    await _progressService.TestDeleteProgressAsync(id);
 081    return Ok();
 082  }
 83
 84  [HttpDelete("{id}")]
 85  [ProducesResponseType(StatusCodes.Status204NoContent)]
 86  [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
 87  [ProducesResponseType(StatusCodes.Status404NotFound)]
 88  public async Task<ActionResult> DeleteProgress(int id)
 089  {
 090    await _progressService.TestDeleteProgressAsync(id);
 091    await _progressService.DeleteProgressAsync(id);
 092    return NoContent();
 093  }
 94}