Example #1
0
        public async Task <IActionResult> LoginAthlete([FromQuery] string username, [FromQuery] string password)
        {
            var response = new SingleModelResponse <Athlete>()
                           as ISingleModelResponse <Athlete>;

            try
            {
                if (username == null)
                {
                    throw new Exception("Athlete Email is null");
                }
                if (password == null)
                {
                    throw new Exception("Athlete Password is null");
                }
                response.Model = await Task.Run(() =>
                {
                    Athlete athlete = _context.LoginAthlete(username, password);
                    if (athlete == null)
                    {
                        throw new Exception("Invalid Login Attempt");
                    }
                    return(athlete);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }