< Summary

Information
Class: OzonOrdersWeb.Areas.Studio2.Controllers.ExcludedBitrixWarehouseController
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/Studio2/Controllers/ExcludedBitrixWarehouseController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 40
Coverable lines: 40
Total lines: 86
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
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%
Create()0%2040%
Create()0%620%
Delete()0%620%
DeleteConfirmed()0%620%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/Studio2/Controllers/ExcludedBitrixWarehouseController.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Mvc;
 2using OzonDomains.Models;
 3using Services.DataServices;
 4using System.Threading.Tasks;
 5using Services.ApiServices;
 6
 7namespace OzonOrdersWeb.Areas.Studio2.Controllers
 8{
 9    [Area("Studio2")]
 10    public class ExcludedBitrixWarehouseController : Controller
 11    {
 12        private readonly ExcludedBitrixWarehouseDataServices _dataService;
 13        private readonly OneCDataManager _oneCDataManager;
 14
 015        public ExcludedBitrixWarehouseController(ExcludedBitrixWarehouseDataServices dataService,
 016            OneCDataManager oneCDataManager)
 17        {
 018            _dataService = dataService;
 019            _oneCDataManager = oneCDataManager;
 020        }
 21
 22        public async Task<IActionResult> Index()
 23        {
 024            var items = await _dataService.GetExcludedBitrixWarehouses();
 025            return View(items);
 026        }
 27
 28        [HttpGet]
 29        public async Task<IActionResult> Create()
 30        {
 031            var warehouses = await _oneCDataManager.GetWarehouseListAsync();
 32
 033            ViewBag.BitrixWarehouses = warehouses
 034                .Select(x => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
 035                {
 036                    Text = x.Name,
 037                    Value = x.Name
 038                }).ToList();
 39
 040            ViewBag.OzonWarehouses = warehouses
 041                .Select(x => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
 042                {
 043                    Text = x.Name,
 044                    Value = x.Name
 045                }).ToList();
 46
 047            return View(new ExcludedBitrixWarehouse());
 048        }
 49
 50        [HttpPost]
 51        [ValidateAntiForgeryToken]
 52        public async Task<IActionResult> Create(ExcludedBitrixWarehouse model)
 53        {
 054            if (!ModelState.IsValid)
 055                return View(model);
 56
 057            await _dataService.AddExcludedBitrixWarehouse(model);
 058            TempData["SuccessMessage"] = $"Склад '{model.Name}' успешно добавлен в исключения.";
 059            return RedirectToAction(nameof(Index));
 060        }
 61
 62        [HttpGet]
 63        public async Task<IActionResult> Delete(int id)
 64        {
 065            var item = await _dataService.GetExcludedBitrixWarehouseAsync(id);
 066            if (item == null)
 067                return NotFound();
 68
 069            return View(item);
 070        }
 71
 72        [HttpPost, ActionName("Delete")]
 73        [ValidateAntiForgeryToken]
 74        public async Task<IActionResult> DeleteConfirmed(int id)
 75        {
 076            var item = await _dataService.GetExcludedBitrixWarehouseAsync(id);
 077            if (item != null)
 78            {
 079                await _dataService.DeleteExcludedBitrixWarehouse(item);
 080                TempData["SuccessMessage"] = $"Склад '{item.Name}' удалён из исключений.";
 81            }
 82
 083            return RedirectToAction(nameof(Index));
 084        }
 85    }
 86}