public ActionResult Login(Patient patient, GeneralPractioner generalPractioner)
        {
            var account = _context.Patient.Where(u => u.UserName == patient.UserName &&
                                                 u.Password == patient.Password).FirstOrDefault();

            var account2 = _context.GeneralPractioner.Where(u => u.UserName == generalPractioner.UserName &&
                                                            u.Password == generalPractioner.Password).FirstOrDefault();

            if (account != null)
            {
                HttpContext.Session.SetString("PatientId", account.PatientId.ToString());
                HttpContext.Session.SetString("UserName", account.UserName);
                return(View("Welcome", patient));
            }
            else if (account2 != null)
            {
                HttpContext.Session.SetString("UserId", account2.UserId.ToString());
                HttpContext.Session.SetString("UserName", account2.UserName);
                return(View("Welcome", generalPractioner));
            }
            else
            {
                ModelState.AddModelError("", "username or pass is wrong");
            }
            return(View());
        }
        public ActionResult GPRegister(GeneralPractioner generalPractioner)
        {
            if (ModelState.IsValid)
            {
                _context.GeneralPractioner.Add(generalPractioner);
                _context.SaveChanges();

                ModelState.Clear();
                ViewBag.message = generalPractioner.FirstName + " " + generalPractioner.LastName +
                                  " is successful registered";
            }
            else
            {
                ViewBag.message = "register failed.";
            }
            return(View());
        }
Exemple #3
0
 public void AddPatient([FromBody] GeneralPractioner patient)
 {
     _context.Add(patient);
 }
Exemple #4
0
 public void AddGeneralPractioner([FromBody] GeneralPractioner generalPractioner)
 {
     _context.Add(generalPractioner);
 }