public ActionResult EditGrade(Guid commodity, Guid gradeId, string name, string code, string description, int usageTypeId) { CommodityGradeViewModel cvm = new CommodityGradeViewModel { CommodityId = commodity, Id = gradeId, Name = name, Code = code, Description = description, UsageTypeId = usageTypeId }; return View(cvm); }
public ActionResult EditGrade(CommodityGradeViewModel aplvm) { try { Guid gradeId = aplvm.Id; Guid commodityId = aplvm.CommodityId; string commodityGradeName = aplvm.Name; int usageTypeId = aplvm.UsageTypeId; string commodityGradeCode = aplvm.Code; string commodityGradeDescription = aplvm.Description; _commodityViewModelBuilder.AddCommodityGrades (commodityId, gradeId, commodityGradeName, usageTypeId, commodityGradeCode, commodityGradeDescription); return RedirectToAction("ListGrades", new { commodity = commodityId }); } catch (DomainValidationException ve) { ValidationSummary.DomainValidationErrors(ve, ModelState); ViewBag.msg2 = ve.Message; Log.ErrorFormat("Error in editing commodity grade" + ve.Message); Log.InfoFormat("Error in editing commodity grade" + ve.Message); return View(); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); ViewBag.msg2 = ex.Message; Log.ErrorFormat("Error in editing commodity grade" + ex.Message); Log.InfoFormat("Error in editing commodity grade" + ex.Message); return View(); } }
public ActionResult AddCommodityGrade(Guid? commodity) { if (commodity.HasValue) { CommodityGradeViewModel cvm = new CommodityGradeViewModel { CommodityId = commodity.Value }; return View(cvm); } else { CommodityGradeViewModel cvm2 = new CommodityGradeViewModel { CommodityId = Guid.NewGuid() }; return View("AddCommodityGrade", cvm2); } }