Exemple #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);
        }
Exemple #2
0
        public OperationResponse <List <UserModelGeneralDto> > GetAllPaged(int take, int page)
        {
            OperationResponse <List <UserModelGeneralDto> > response = new OperationResponse <List <UserModelGeneralDto> >();

            try
            {
                int total = 0;
                var users = _serviceUser.ListUserPaged(page, take, out total);

                response.Data  = users;
                response.Count = total;
                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Success_List, Type = OperationMessageTypes.Success
                });
            }
            catch (Exception ex)
            {
                _serviceLog.Add(LogHelper.GenerateLog(ControllerContext, "GetAllPaged", UserResource.User_Error_List, CurrentUser.Email, ex));
                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Error_List + " : " + ex.Message, Type = OperationMessageTypes.Error
                });
            }

            return(response);
        }
Exemple #3
0
        public OperationResponse <bool> DeleteUser(Guid usuarioId)
        {
            OperationResponse <bool> response = new OperationResponse <bool>();

            try
            {
                _serviceUser.DeleteUser(usuarioId);
                response.Data = true;
                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Success_Delete, Type = OperationMessageTypes.Success
                });
            }
            catch (Exception ex)
            {
                _serviceLog.Add(LogHelper.GenerateLog(ControllerContext, "DeleteUser", UserResource.User_Error_Delete, CurrentUser.Email, ex));
                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Error_Delete + " : " + ex.Message, Type = OperationMessageTypes.Error
                });
            }

            return(response);
        }
Exemple #4
0
        public OperationResponse <Guid> AddUser([FromBody] UserModelCreateDto user)
        {
            OperationResponse <Guid> response = new OperationResponse <Guid>();

            try
            {
                var result = _serviceUser.AddUser(user);
                response.Data = result;
                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Success_Create, Type = OperationMessageTypes.Success
                });
            }
            catch (Exception ex)
            {
                _serviceLog.Add(LogHelper.GenerateLog(ControllerContext, "AddUser", UserResource.User_Error_Create, CurrentUser.Email, ex));
                response.Messages.Add(new OperationMessage {
                    Description = UserResource.User_Error_Create + " : " + ex.Message, Type = OperationMessageTypes.Error
                });
            }

            return(response);
        }