public ActionResult Create(long Id = 0) { ViewBag.SuccessMessage = ""; PriceBookFormModel priceBookFormModel = new PriceBookFormModel(); if(Id != 0) { PriceBook priceBook = priceBookService.GetPriceBook(Id); priceBookFormModel = AutoMapper.Mapper.Map<PriceBook, PriceBookFormModel>(priceBook); } return View("PriceBookCreate", priceBookFormModel); }
public ActionResult Create(PriceBookFormModel priceBookmodel) { try { PriceBook priceBook = AutoMapper.Mapper.Map<PriceBookFormModel, PriceBook>(priceBookmodel); priceBook.AssignedTo = 0; if (ModelState.IsValid) { if (priceBook.ID == 0) { priceBookService.CreatePriceBook(priceBook); } else { priceBookService.EditPriceBook(priceBook); } ViewBag.successMessage = "PriceBook Saved Successfully"; ViewBag.errorMessage = ""; } else { string validationErrors = string.Join(",", ModelState.Values.Where(E => E.Errors.Count > 0) .SelectMany(E => E.Errors).Select(E => E.ErrorMessage).ToArray()); ViewBag.successMessage = ""; ViewBag.errorMessage = validationErrors; } } catch (Exception ex) { ViewBag.successMessage = ""; ViewBag.errorMessage = string.Format("Error in PriceBook Save : {0}", ex.Message); } return View("PriceBookCreate", priceBookmodel); }
public ActionResult Details(long Id) { PriceBookFormModel priceBookDetails = new PriceBookFormModel(); PriceBook priceBook = priceBookService.GetPriceBook(Id); priceBookDetails = AutoMapper.Mapper.Map<PriceBook, PriceBookFormModel>(priceBook); return View("PriceBookDetails", priceBookDetails); }