コード例 #1
0
ファイル: AccountController.cs プロジェクト: himanshu74/WYS
        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);
        }
コード例 #2
0
ファイル: Mapper.cs プロジェクト: himanshu74/WYS
        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);
        }
コード例 #3
0
ファイル: UserBo.cs プロジェクト: himanshu74/WYS
        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);
        }
コード例 #4
0
 public UsersController(IUserBo userBo)
 {
     _userBo = userBo;
 }
コード例 #5
0
 public CustomerController(IUserBo userBo, IMapper mapper)
 {
     _userBo = userBo;
     _mapper = mapper;
 }