< Summary

Information
Class: OzonOrdersWeb.Areas.OzonCards.Controllers.ExcelMappingsController
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/OzonCards/Controllers/ExcelMappingsController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 67
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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(...)100%210%
Index()100%210%
Save()0%2040%
Load()100%210%
Delete()100%210%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/OzonCards/Controllers/ExcelMappingsController.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Authorization;
 2using Microsoft.AspNetCore.Mvc;
 3using OzonOrdersWeb.Areas.OzonCards.ViewModels;
 4using Services.DataServices.ExcelMapping;
 5
 6namespace OzonOrdersWeb.Areas.OzonCards.Controllers
 7{
 8    [Area("OzonCards")]
 9    [Authorize(Roles = "User,Admin")]
 10    public class ExcelMappingsController : Controller
 11    {
 12        private readonly IExcelMappingService _mappingService;
 13
 014        public ExcelMappingsController(IExcelMappingService mappingService)
 15        {
 016            _mappingService = mappingService;
 017        }
 18
 19        public async Task<IActionResult> Index()
 20        {
 021            var mappings = await _mappingService.GetAllMappingsAsync();
 022            return View(mappings);
 023        }
 24
 25        [HttpPost]
 26        public async Task<IActionResult> Save(ExcelMappingRequest request, string mappingName)
 27        {
 28            try
 29            {
 030                var id = await _mappingService.SaveMappingAsync(request, mappingName, User.Identity?.Name ?? string.Empt
 031                return Json(new { success = true, id });
 32            }
 033            catch (Exception ex)
 34            {
 035                return Json(new { success = false, message = ex.Message });
 36            }
 037        }
 38
 39        [HttpGet]
 40        public async Task<IActionResult> Load(int id)
 41        {
 42            try
 43            {
 044                var mapping = await _mappingService.GetMappingAsync(id);
 045                return Json(new { success = true, data = mapping });
 46            }
 047            catch (Exception ex)
 48            {
 049                return Json(new { success = false, message = ex.Message });
 50            }
 051        }
 52
 53        [HttpDelete]
 54        public async Task<IActionResult> Delete(int id)
 55        {
 56            try
 57            {
 058                await _mappingService.DeleteMappingAsync(id);
 059                return Json(new { success = true });
 60            }
 061            catch (Exception ex)
 62            {
 063                return Json(new { success = false, message = ex.Message });
 64            }
 065        }
 66    }
 67}