Пример #1
0
        public OperationResponse <UserModelGeneralDto> GetById(Guid usuarioId)
        {
            OperationResponse <UserModelGeneralDto> response = new OperationResponse <UserModelGeneralDto>();

            try
            {
                var user = _serviceUser.GetUserById(usuarioId);

                var address = _serviceAddress.GetAddressByUserId(usuarioId);

                if (address != null)
                {
                    user.Address = address;
                }

                response.Data = user;
                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Success_Search, Type = OperationMessageTypes.Success
                });
            }
            catch (Exception ex)
            {
                _serviceLog.Add(LogHelper.GenerateLog(ControllerContext, "GetById", UserResource.User_Error_Search, CurrentUser.Email, ex));

                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Error_Search + " : " + ex.Message, Type = OperationMessageTypes.Error
                });
            }

            return(response);
        }
        public OperationResponse <AddressModelGeneralDto> GetAddressByUserId(Guid usuarioId)
        {
            OperationResponse <AddressModelGeneralDto> response = new OperationResponse <AddressModelGeneralDto>();

            try
            {
                var address = _serviceAddress.GetAddressByUserId(usuarioId);

                if (address == null)
                {
                    response.Messages.Add(new OperationMessage {
                        Description = "Falha: Usuario ou Endereço invalido", Type = OperationMessageTypes.Error
                    });
                }
                else
                {
                    response.Data = address;
                    response.Messages.Add(new OperationMessage {
                        Description = "Sucesso", Type = OperationMessageTypes.Success
                    });
                }
            }
            catch (Exception ex)
            {
                response.Messages.Add(new OperationMessage {
                    Description = "Falha: " + ex.Message, Type = OperationMessageTypes.Error
                });
            }

            return(response);
        }