public ActionResult PrescriptionUpload(PrescriptionUpload file) { if (ModelState.IsValid) { var email = (string)Session["Email"]; if (obj1.Patients.Where(m => m.id == file.patient_id).FirstOrDefault() != null) { Doctor Dia = new Data.Doctor(); Dia = obj1.Doctors.Where(m => m.email == email).FirstOrDefault(); Prescription P = new Data.Prescription(); P.doc_id = Dia.id; P.patient_id = file.patient_id; P.date_time = DateTime.Now; byte[] data; using (BinaryReader br = new BinaryReader(file.data.InputStream)) { data = br.ReadBytes(file.data.ContentLength); } P.dataname = Path.GetFileName(file.data.FileName); P.datatype = file.data.ContentType; P.data = data; obj1.Prescriptions.Add(P); obj1.SaveChanges(); ViewBag.a = "Successfully Added"; return(RedirectToAction("DoctorSearching", "DoctorSearchingPatient")); } else { ViewBag.a = "Patient ID not exist"; return(View("PrescriptionUpload")); } } return(View()); }
public ActionResult SignUp(Signup user) { if (ModelState.IsValid) { if (string.Equals(user.usertype, "Patient")) { if (!(obj1.Patients.Where(m => m.email == user.email).FirstOrDefault() == null)) { ViewBag.a = "Account already exists"; } else { if (string.Equals(user.password, user.confirmpassword)) { Patient pa = new Data.Patient(); pa.name = user.name; pa.email = user.email; pa.password = user.confirmpassword; obj1.Patients.Add(pa); obj1.SaveChanges(); ViewBag.a = "Successfully Added"; return(RedirectToAction("Login", "Login")); } else { ViewBag.a = "Password not match"; return(View("SignUp")); } } } else if (string.Equals(user.usertype, "Doctor")) { if (!(obj2.Doctors.Where(m => m.email == user.email).FirstOrDefault() == null)) { ViewBag.a = "Account already exists"; } else { if (string.Equals(user.password, user.confirmpassword)) { Doctor doc = new Data.Doctor(); doc.name = user.name; doc.email = user.email; doc.password = user.confirmpassword; obj2.Doctors.Add(doc); obj2.SaveChanges(); ViewBag.a = "Successfully Added"; return(RedirectToAction("Login", "Login")); } else { ViewBag.a = "Password not match"; return(View("SignUp")); } } } else if (string.Equals(user.usertype, "DrugStore")) { if (!(obj3.DrugStores.Where(m => m.email == user.email).FirstOrDefault() == null)) { ViewBag.a = "Account already exists"; } else { if (string.Equals(user.password, user.confirmpassword)) { DrugStore dru = new Data.DrugStore(); dru.name = user.name; dru.email = user.email; dru.password = user.confirmpassword; obj3.DrugStores.Add(dru); obj3.SaveChanges(); ViewBag.a = "Successfully Added"; return(RedirectToAction("Login", "Login")); } else { ViewBag.a = "Password not match"; return(View("SignUp")); } } } else if (string.Equals(user.usertype, "DiagnosticCenter")) { if (!(obj4.DiagnosticCenters.Where(m => m.email == user.email).FirstOrDefault() == null)) { ViewBag.a = "Account already exists"; } else { if (string.Equals(user.password, user.confirmpassword)) { DiagnosticCenter dia = new Data.DiagnosticCenter(); dia.name = user.name; dia.email = user.email; dia.password = user.confirmpassword; obj4.DiagnosticCenters.Add(dia); obj4.SaveChanges(); ViewBag.a = "Successfully Added"; return(RedirectToAction("Login", "Login")); } else { ViewBag.a = "Password not match"; return(View("SignUp")); } } } } return(View()); }