示例#1
0
        public async Task <Tuple <string, UserHostService.User> > Authentication(string userName, string password)
        {
            string error = "";

            UserHostService.User result = null;

            if (userName == "autorizador")
            {
                if (password == "12345")
                {
                    result = new UserHostService.User()
                    {
                        UserId   = 1,
                        UserName = "******",
                        Customer = new UserHostService.Customer()
                        {
                            CustomerId = 1,
                            FullName   = "Pepito Mendieto"
                        },
                        CustomerId = 1
                    }
                }
                ;
                else
                {
                    error = "Contraseña incorrecta";
                }
            }
            else
            {
                error = "El usuario no existe";
            }

            return(new Tuple <String, UserHostService.User>(error, result));
        }
示例#2
0
        public ResponseModel <UserHostService.User> GetCurrentAuthenticated()
        {
            IDataService ds = new MockDataService();

            var response   = new ResponseModel <UserHostService.User>();
            var data       = new UserHostService.User();
            var statusCode = new HttpStatusCode();
            var identity   = (ClaimsIdentity)User.Identity;

            try
            {
                data             = ds.GetUserById(Convert.ToInt32(identity.Claims.Where(x => x.Type == "IdUser").FirstOrDefault().Value));
                response.Success = true;
                statusCode       = data == null ? HttpStatusCode.NoContent : HttpStatusCode.OK;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = ex.Message;
                statusCode       = HttpStatusCode.InternalServerError;
            }

            response.Data = data;

            return(SendResponse(response, statusCode));
        }
示例#3
0
        public UserHostService.User GetUserById(int id)
        {
            UserHostService.User obj = null;

            if (id == 1)
            {
                obj = new UserHostService.User()
                {
                    UserId   = 1,
                    UserName = "******",
                    Customer = new UserHostService.Customer()
                    {
                        CustomerId = 1,
                        FullName   = "Pepito Mendieto"
                    },
                    CustomerId = 1
                };
            }

            return(obj);
        }