public ActionResult Add(LocationDO model, string saveAndNewButton)
        {
            try
            {
                LocationBL.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 ActionResult Edit(LocationDO model)
        {
            try
            {
                LocationBL.Save(model, this.UserID);
                SetSuccessMessage();
            }
            catch (BusinessException e)
            {
                SetErrorMessage(e.Message);
            }

            return RedirectToAction("Edit", new { id = model.ID });
        }
 public ActionResult Add()
 {
     LocationDO model = new LocationDO();
     return View(model);
 }
Exemplo n.º 4
0
        public static void Save(LocationDO model, int userID)
        {
            Repository<Location> rep = new Repository<Location>(CheckoutDataContextProvider.Instance);
            Location dbObject;

            if (model.ID == 0)
            {
                dbObject = new Location();
                Mapper.Map<LocationDO, Location>(model, dbObject);
                rep.InsertOnSubmit(dbObject);
            }
            else
            {
                dbObject = rep.GetAll().Where(x => x.ID == model.ID).SingleOrDefault();
                Mapper.Map<LocationDO, Location>(model, dbObject);
            }

            rep.DCP.CommitChanges(userID);
            Mapper.Map<Location, LocationDO>(dbObject, model);
        }