2015-05-22 17:45:18 +08:00
|
|
|
using System;
|
2015-04-25 12:31:01 +08:00
|
|
|
using System.Linq;
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
using OpenAuth.App.DTO;
|
|
|
|
using OpenAuth.Domain.Interface;
|
|
|
|
using OpenAuth.Domain.Service;
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
{
|
|
|
|
public class LoginApp
|
|
|
|
{
|
|
|
|
private LoginService _loginService;
|
|
|
|
|
2015-05-22 17:45:18 +08:00
|
|
|
public LoginApp(LoginService service)
|
2015-04-25 12:31:01 +08:00
|
|
|
{
|
2015-05-22 17:45:18 +08:00
|
|
|
_loginService = service;
|
2015-04-25 12:31:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public LoginResponse Login(LoginRequest request)
|
|
|
|
{
|
|
|
|
var resp = new LoginResponse {UserName = request.UserName};
|
|
|
|
|
2015-05-22 17:45:18 +08:00
|
|
|
try
|
2015-04-25 12:31:01 +08:00
|
|
|
{
|
2015-05-22 17:45:18 +08:00
|
|
|
var user = _loginService.Login(request.UserName, request.Password);
|
|
|
|
resp.UserId = user.Id;
|
|
|
|
resp.Success = true;
|
2015-04-25 12:31:01 +08:00
|
|
|
}
|
2015-05-22 17:45:18 +08:00
|
|
|
catch (Exception ex)
|
2015-04-25 12:31:01 +08:00
|
|
|
{
|
2015-05-22 17:45:18 +08:00
|
|
|
resp.Success = false;
|
|
|
|
resp.Message = ex.Message;
|
2015-04-25 12:31:01 +08:00
|
|
|
}
|
2015-05-22 17:45:18 +08:00
|
|
|
|
2015-04-25 12:31:01 +08:00
|
|
|
return resp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|