public BaseResponse UpdateUser(UserModelRequest entity) { try { var userEntity = entity.MapTo <UserEntity>(); var usermodel = userRepository.GetUser(userEntity.UserId); if (usermodel == null) { return new BaseResponse { IsSuccess = false, Msg = "can not find mddel" } } ; bool result = userRepository.UpdateUser(usermodel); return(result ? new BaseResponse { IsSuccess = true } : new BaseResponse { IsSuccess = false }); } catch (Exception ex) { return(new BaseResponse { IsSuccess = false, Msg = ex.Message }); } }
public BaseResponse DeleteUser(UserModelRequest entity) { var userEntity = entity.MapTo <UserEntity>(); userRepository.DeleteUser(userEntity); return(new BaseResponse { IsSuccess = true }); }
public UserModelResponse AddUser(UserModelRequest entity) { var userEntity = entity.MapTo <UserEntity>(); userEntity.CreateTime = DateTime.Now; userEntity.UpdateTime = DateTime.Now; long id = userRepository.AddUser(userEntity); return(id > 0 ? new UserModelResponse { UserId = id, IsSuccess = true } : new UserModelResponse { IsSuccess = false, UserId = 0 }); }
public BaseResponse DeleteUser(UserModelRequest entity) { try { var userEntity = entity.MapTo <UserEntity>(); userRepository.DeleteUser(userEntity); return(new BaseResponse { IsSuccess = true }); } catch (Exception ex) { return(new BaseResponse { IsSuccess = false, Msg = ex.Message }); } }
public UserModelResponse AddUser(UserModelRequest entity) { try { var userEntity = entity.MapTo <UserEntity>(); long id = userRepository.AddUser(userEntity); return(id > 0 ? new UserModelResponse { UserId = id, IsSuccess = true } : new UserModelResponse { IsSuccess = false, UserId = 0 }); } catch (Exception ex) { return(new UserModelResponse { UserId = 0, IsSuccess = false, Msg = ex.Message }); } }
public BaseResponse UpdateUser(UserModelRequest entity) { var userEntity = entity.MapTo <UserEntity>(); var usermodel = userRepository.GetUser(userEntity.UserId); if (usermodel == null) { return new BaseResponse { IsSuccess = false, Msg = "can not find user" } } ; usermodel.UpdateTime = DateTime.Now; usermodel.UserName = entity.UserName; bool result = userRepository.UpdateUser(usermodel); return(result ? new BaseResponse { IsSuccess = true } : new BaseResponse { IsSuccess = false }); }