Exemple #1
0
        public IActionResult Get()
        {
            RepositoryXml <User> userRepository = new RepositoryXml <User>(userXmlPath);
            IEnumerable <User>   users          = userRepository.GetAll();

            return(new ObjectResult(users));
        }
Exemple #2
0
        public IActionResult Login(string email, string password)
        {
            // TODO: Handle login using tokens instead of user Id.

            RepositoryXml <User> userRepository = new RepositoryXml <User>(userXmlPath);
            User user = userRepository.GetAll().FirstOrDefault(x => x.EmailAddress.ToLower() == email.ToLower());

            bool success = user?.Password == password;

            if (success)
            {
                return(new ObjectResult(new { success, userId = user.Id }));
            }
            else
            {
                return(new ObjectResult(new { success }));
            }
        }