public UserBo Login(String username, String password) { if (String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password)) { var message = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("Username or Password is not provided") }; throw new HttpResponseException(message); } try { IUserBo userBo = new UserBo(); IUserBo user = userBo.ValidateUser(username); if (PasswordManager.ValidatePassword(password, user.Password)) { if (user.IsVerified == Verified) { String token = TokenManager.GetToken(); if (userBo.UpdateToken(token, username)) { user.Token = token; user.Password = password; return((UserBo)user); } } else { return((UserBo)user); } } else { var message = new HttpResponseMessage(HttpStatusCode.Unauthorized) { Content = new StringContent("Username or Password is Incorrect") }; throw new HttpResponseException(message); } } catch (Exception exception) { _logger.Error("FRONT LAYER =>> CONTROLLER =>> LOGIN, METHOD =>> LOGIN, EXCEPTION MESSAGE: " + exception.Message); HttpResponseHelper.GetInternalServerErrorResponse(exception); } return(null); }
public static IUserBo ToUserBo(UserDto userDto) { IUserBo userBo = null; try { Mapper.CreateMap <UserDto, UserBo>(); userBo = Mapper.Map <UserBo>(userDto); } catch (Exception exception) { Logger.Error("API LAYER: ERROR IN CLASS: MAPPERAPI, METHOD: ToUserBo =>> EXCEPTION MESSAGE: " + exception.Message); throw; } return(userBo); }
public IUserBo GetByid(int userId) { var userDao = DataAccess.UserDao; IUserBo user = null; try { var ds = userDao.GetById(userId); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { user = MapperBo.ToUserBo(ds.Tables[0].Rows[0]); } } catch (Exception exception) { _logger.Error("ERROR IN CLASS =>>> USERBO, METHOD =>>> GetByid, EXCEPTION MESSAGE =>> " + exception.Message); throw; } return(user); }
public UsersController(IUserBo userBo) { _userBo = userBo; }
public CustomerController(IUserBo userBo, IMapper mapper) { _userBo = userBo; _mapper = mapper; }