Esempio n. 1
0
        public ResponseMessage Edit(Address entity)
        {
            ResponseMessage response = new ResponseMessage();

            if (_repository.IsAddressExist(entity.Street, entity.Number, entity.Id))
            {
                response.IsError = true;
                response.ErrorCodes.Add("Address Already Exist");
                return(response);
            }

            _repository.Edit(entity);

            return(response);
        }
Esempio n. 2
0
        public Address Edit(long userId, Address toEdit)
        {
            using (var tran = new TransactionScope())
            {
                if (toEdit.EntryDate == DateTime.MinValue)
                {
                    toEdit.EntryDate = BlCommon.GetServerDateTime();
                }

                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit address", "AddressModified", new object[] { toEdit.Sequence, toEdit.Entity.Pin, BlEntity.FormatFullName(toEdit.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
        public ActionResult Edit(ClientSubUnitTravelerTypeAddressVM clientSubUnitTravelerTypeAddressVM)
        {
            int clientDetailId = clientSubUnitTravelerTypeAddressVM.ClientDetail.ClientDetailId;

            ClientDetail clientDetail = new ClientDetail();

            clientDetail = clientDetailRepository.GetGroup(clientDetailId);

            //Check Exists
            if (clientDetail == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                return(View("RecordDoesNotExistError"));
            }

            ClientDetailClientSubUnitTravelerType clientDetailClientSubUnitTravelerType = new ClientDetailClientSubUnitTravelerType();

            clientDetailClientSubUnitTravelerType = clientDetailClientSubUnitTravelerTypeRepository.GetClientDetailClientSubUnitTravelerType(clientDetailId);

            //Check Exists
            if (clientDetailClientSubUnitTravelerType == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                return(View("RecordDoesNotExistError"));
            }

            string csu = clientDetailClientSubUnitTravelerType.ClientSubUnitGuid;
            string tt  = clientDetailClientSubUnitTravelerType.TravelerTypeGuid;


            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu);

            //Check Exists
            if (clientSubUnit == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                return(View("RecordDoesNotExistError"));
            }

            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToClientSubUnit(csu))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }


            //Update  Model from Form
            try
            {
                TryUpdateModel <Address>(clientSubUnitTravelerTypeAddressVM.Address, "Address");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }



            try
            {
                addressRepository.Edit(clientSubUnitTravelerTypeAddressVM.Address);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }


            return(RedirectToAction("List", new { id = clientDetailId }));
        }