コード例 #1
0
        public IActionResult Login(IFormCollection Form)

        {
            /// taking in login form from index.cshtml and gathering variables
            string username = (Form["UserName"].ToString());
            string password = (Form["Password"].ToString());

            //validation of "admin" credentials
            if (username == "Admin" && password == "Admin")
            {
                //initializing session variables
                HttpContext.Session.SetString("Username", username);
                HttpContext.Session.SetString("Password", password);
                return(View("Options"));
            }
            else
            {
                foreach (var volunteer in _volunteerRepository.GetAllVolunteers())
                {
                    if (volunteer.Username == username && volunteer.Password == password)
                    {
                        HttpContext.Session.SetString("Username", username);
                        HttpContext.Session.SetString("Password", password);
                        return(RedirectToAction("VolunteerOptions"));
                    }
                }

                ViewBag.error = "Username: Admin<br />Password: Admin";
                return(View("Index"));
            }
        }
コード例 #2
0
 private async Task <IEnumerable <Data.Model.Volunteer> > GetVolunteerInternal()
 {
     return(await _volunteerRepository.GetAllVolunteers());
 }
コード例 #3
0
        public ActionResult <IEnumerable <Volunteers> > GetAllVolunteers()
        {
            var volunteersList = _volunteers.GetAllVolunteers();

            return(Ok(_mapper.Map <IEnumerable <VolunteerReadDto> >(volunteersList)));
        }