public ActionResult Add(Store_LocationDO model, string saveAndNewButton) { try { CollectionPackagingCenterBL.Save(model, this.UserID); SetSuccessMessage(); } catch (BusinessException e) { SetErrorMessage(e.Message); return RedirectToAction("Add"); } if (string.IsNullOrEmpty(saveAndNewButton) == true) return RedirectToAction("Edit", new { id = model.ID }); else return RedirectToAction("Add"); }
public static void Save(Store_LocationDO model, int userID) { Repository<Store_Location> rep = new Repository<Store_Location>(CheckoutDataContextProvider.Instance); Store_Location dbObject; if (model.ID == 0) { dbObject = new Store_Location(); Mapper.Map<Store_LocationDO, Store_Location>(model, dbObject); rep.InsertOnSubmit(dbObject); } else { dbObject = rep.GetAll().Where(x => x.ID == model.ID).SingleOrDefault(); Mapper.Map<Store_LocationDO, Store_Location>(model, dbObject); } rep.DCP.CommitChanges(userID); Mapper.Map<Store_Location, Store_LocationDO>(dbObject, model); }
public ActionResult Edit(Store_LocationDO model) { try { CollectionPackagingCenterBL.Save(model, this.UserID); SetSuccessMessage(); } catch (BusinessException e) { SetErrorMessage(e.Message); } return RedirectToAction("Edit", new { id = model.ID }); }
public ActionResult Add() { Store_LocationDO model = new Store_LocationDO(); return View(model); }