public ActionResult Edit(UserLocationDO model)
 {
     try
     {
         UserLocationBL.Save(model, this.UserID);
         SetSuccessMessage();
     }
     catch (BusinessException e)
     {
         SetErrorMessage(e.Message);
     }
     
     return RedirectToAction("Edit", new { id = model.ID });
 }
        public ActionResult Add(UserLocationDO model, string saveAndNewButton)
        {
            try
            {
                UserLocationBL.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(UserLocationDO model, int userID)
        {
            Repository<UserLocation> rep = new Repository<UserLocation>(CheckoutDataContextProvider.Instance);
            UserLocation dbObject;
            if (rep.GetAll().Where(x => x.UserName == model.UserName && x.LocationID == model.LocationID).SingleOrDefault() != null)
            {
                throw new BusinessException("Bu kullanıcı için bu lokasyon tanımlanmış");
            }

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

            rep.DCP.CommitChanges(userID);
            Mapper.Map<UserLocation, UserLocationDO>(dbObject, model);
        }
 public ActionResult Add()
 {
     UserLocationDO model = new UserLocationDO();
     return View(model);
 }