public bool Issue(IRViewModel issueModel) { var issue = _mapper.Map <IRViewModel, Storage>(issueModel); issue.IsIssued = true; try { var product = _context.Products.Find(issueModel.ProductId); if (product.QuantityIndex >= issueModel.Quantity) { product.QuantityIndex -= issueModel.Quantity; _context.Add(issue); _context.Update(product); _context.SaveChanges(); return(true); } else { return(false); } } catch (DbUpdateException) { return(false); } }
public IActionResult Receive([FromBody] IRViewModel model) { if (_storageService.Receive(model)) { return(StatusCode(200)); } else { return(StatusCode(400)); } }
public JsonResult GetTypeOfCases() { var currentUserId = User.Identity.GetUserId(); List <IRViewModel> pvm = new List <IRViewModel>(); var results = db.CounsellingFormCasesList.ToList(); foreach (CounsellingFormCasesList item in results) { IRViewModel viewmodel = new IRViewModel(); viewmodel.name = item.Type; pvm.Add(viewmodel); } return(Json(pvm, JsonRequestBehavior.AllowGet)); }
public JsonResult GetTypeOfIncidents() { var currentUserId = User.Identity.GetUserId(); List <IRViewModel> pvm = new List <IRViewModel>(); var results = db.IncidentReportIncidents.ToList(); foreach (IncidentReportIncidents incident in results) { IRViewModel viewmodel = new IRViewModel(); viewmodel.name = incident.Type; pvm.Add(viewmodel); } return(Json(pvm, JsonRequestBehavior.AllowGet)); }
public bool Receive(IRViewModel receiveModel) { var receive = _mapper.Map <IRViewModel, Storage>(receiveModel); try { var product = _context.Products.Find(receiveModel.ProductId); product.QuantityIndex += receiveModel.Quantity; _context.Add(receive); _context.Update(product); _context.SaveChanges(); return(true); } catch (DbUpdateException) { return(false); } }