示例#1
0
        public LoginResult Login(string username, string password)
        {
            int resultInt;
            User user = _repo.Login(username, password, out resultInt);
            LoginStatus status = (LoginStatus)resultInt;
            LoginResult result = new LoginResult();
            switch (status)
            {
                case (LoginStatus.Success):
                    result.ResultString = ResultCodes.LoginSuccess;
                    result.UserId = user.Id;
                    result.Username = user.Username;
                    break;
                case (LoginStatus.WrongPass):
                    result.ResultString = ResultCodes.LoginWrongPassword;
                    break;
                case (LoginStatus.WrongUser):
                    result.ResultString = ResultCodes.LoginWrongUser;
                    break;
            }

            return result;
        }
示例#2
0
        LoginResult ITodoService.Login(string username, string password)
        {
            LoginResult result = null;
            try
            {
                int resultInt;
                User user = _repo.Login(username, password, out resultInt);
                LoginStatus status = (LoginStatus)resultInt;
                result = new LoginResult();
                switch (status)
                {
                    case (LoginStatus.Success):
                        result.ResultString = ResultCodes.LoginSuccess;
                        result.UserId = user.Id;
                        result.Username = user.Username;
                        _log.Info(String.Format("Log in Successful for user: {0}", user.Username));
                        break;
                    case (LoginStatus.WrongPass):
                        result.ResultString = ResultCodes.LoginWrongPassword;
                        break;
                    case (LoginStatus.WrongUser):
                        result.ResultString = ResultCodes.LoginWrongUser;
                        break;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                ServiceDataFault fault = new ServiceDataFault()
                {
                    Issue = "Login Fail",
                    Details = ex.ToString()
                };
                throw new FaultException<ServiceDataFault>(fault, new FaultReason(fault.Issue));
            }

            return result;
        }