Пример #1
0
        public override Result <Employee> Update(EmployeeModel model)
        {
            try
            {
                var employee = _mapper.Map <Employee>(model);

                var resultAddress = _addressBLL.Update(model.AddressModel);
                if (!resultAddress.Success)
                {
                    return(Result <Employee> .BuildError(resultAddress.Messages));
                }

                var result = _employeeValidation.Validate(employee);
                if (!result.Success)
                {
                    return(result);
                }

                _employeeDAL.Update(employee);
                var resultSalve = _employeeDAL.Save();
                if (!resultSalve.Success)
                {
                    return(Result <Employee> .BuildError(resultSalve.Messages));
                }

                return(Result <Employee> .BuildSuccess(employee));
            }
            catch (Exception error)
            {
                return(Result <Employee> .BuildError("Erro ao alterar o registro do funcionário.", error));
            }
        }
Пример #2
0
        public ActionResult Editor(AddressModel model, Guid Id)
        {
            Address address = _addressBLL.GetAddressById(Id);

            address.City      = model.City;
            address.Consignee = model.Consignee;
            address.County    = model.County;
            address.Detail    = model.Detail;
            address.Phone     = model.Phone;
            address.Province  = model.Province;

            if (_addressBLL.Update(address))
            {
                return(Json("True", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }
        }
Пример #3
0
        public override Result <Requester> Update(RequesterModel model)
        {
            try
            {
                if (model.AddressId > 0)
                {
                    model.AddressModel.Id = model.AddressId;
                }

                Requester requester     = _mapper.Map <Requester>(model);
                var       resultAddress = _addressBLL.Update(model.AddressModel);
                if (!resultAddress.Success)
                {
                    return(Result <Requester> .BuildError(resultAddress.Messages));
                }

                requester.Address = resultAddress.Model;

                var result = _requesterValidation.Validate(requester);
                if (!result.Success)
                {
                    return(result);
                }

                _requesterDAL.Update(requester);
                var resultSave = _requesterDAL.Save();
                if (!resultSave.Success)
                {
                    return(Result <Requester> .BuildError(resultSave.Messages));
                }

                return(Result <Requester> .BuildSuccess(requester));
            }
            catch (Exception error)
            {
                return(Result <Requester> .BuildError("Erro ao alterar o registro do solicitante.", error));
            }
        }