public void Delete(BuildStandart buildStandart) { _repository.Delete(_mapper.Map <ServiceComponent, СomponetServiceEntity>(new ServiceComponent() { Id = buildStandart.Id })); }
public void Create(BuildStandart buildStandart) { if (BuildStandartServiceValidation.IsValid(buildStandart, Read())) { _repository.Create(_mapper.Map <ServiceComponent, СomponetServiceEntity>(new ServiceComponent() { Id = buildStandart.Id, ComponetId = buildStandart.Componet.Id, ServiceId = buildStandart.Service.Id })); } }
public static bool IsValid(BuildStandart standart, List <BuildStandart> standarts) { if (standart != null && standarts != null) { if (standarts.Any(x => x.Service.Id == standart.Service.Id && x.Componet.Id == standart.Componet.Id)) { throw new ValidationException(Messages.ExsistingCombination); } return(true); } else { throw new ValidationException(Messages.ObjectNotCreatedMessage); } }
public void Add(int count, BuildStandart buildStandart) { if (OrderLine.ContainsKey(buildStandart.Id)) { Line line = OrderLine[buildStandart.Id]; line.Count += count; } else { Line line = new Line() { Count = count, BuildStandart = buildStandart }; OrderLine.Add(buildStandart.Id, line); } }
public ActionResult AddProduct(int count, int builderStandartId) { if (count < 1) { return(RedirectToAction("List", "Product")); } BuildStandart standart = _service.Read(minId: builderStandartId, maxId: builderStandartId).FirstOrDefault(); Cart cart = new Cart(); cart.GetFromCoockie(HttpContext); if (cart == null) { cart = new Cart(); } cart.Add(count, standart); cart.SaveToCoockie(HttpContext); return(RedirectToAction(nameof(ShowCart))); }
public ActionResult CreateBuildStandards(BuildStandart standart) { if (ModelState.IsValid) { try { _buildStandartServices.Create(standart); return(RedirectToAction("BuildStandardsList")); } catch (Exception ex) { ModelState.AddModelError(ex.GetHashCode().ToString(), ex.Message); } } ViewBag.Services = _serviceServices.Read(); ViewBag.Components = _componentServices.Read(); return(View(standart)); }
public void Update(BuildStandart buildStandart, int serviceId = Constants.DefIntVal, int componetId = Constants.DefIntVal) { _repository.Update(_mapper.Map <ServiceComponent, СomponetServiceEntity>(new ServiceComponent { Id = buildStandart.Id }), serviceId, componetId); }
public void Update(BuildStandart сomponetService, int serviceId = -1, int componetId = -1) { _repository.Update(_mapper.Map <BuildStandart, BL.DtoModels.Combined.BuildStandart>(сomponetService), serviceId, componetId); }
public void Delete(BuildStandart сomponetService) { _repository.Delete(_mapper.Map <BuildStandart, BL.DtoModels.Combined.BuildStandart>(сomponetService)); }