public ActionResult ReportUpload(ReportUpload file) { if (ModelState.IsValid) { var email = (string)Session["Email"]; if (obj1.Patients.Where(m => m.id == file.patient_id).FirstOrDefault() != null) { DiagnosticCenter Dia = new Data.DiagnosticCenter(); Dia = obj1.DiagnosticCenters.Where(m => m.email == email).FirstOrDefault(); Report R = new Data.Report(); R.center_id = Dia.id; R.patient_id = file.patient_id; R.date_time = DateTime.Now; byte[] data; using (BinaryReader br = new BinaryReader(file.data.InputStream)) { data = br.ReadBytes(file.data.ContentLength); } R.dataName = Path.GetFileName(file.data.FileName); R.datatype = file.data.ContentType; R.data = data; obj1.Reports.Add(R); obj1.SaveChanges(); ViewBag.a = "Successfully Added"; return(View("ReportUpload")); } else { ViewBag.a = "Patient ID not exist"; } } return(View()); }
public ActionResult ViewProfile() { var user = (string)Session["UserType"]; if (string.Equals(user, "DrugStore")) { var email = (string)Session["Email"]; DrugStore pa = new Data.DrugStore(); pa = obj1.DrugStores.Where(m => m.email == email).FirstOrDefault(); DrugStoreAndDiagnosticCenterViewProfile obj = new DrugStoreAndDiagnosticCenterViewProfile(); obj.email = pa.email; obj.id = pa.id; obj.address = pa.addess; obj.workingHour = pa.working_hour; obj.name = pa.name; obj.contact = pa.contact; obj.type = user; return(View(obj)); } if (string.Equals(user, "DiagnosticCenter")) { var email = (string)Session["Email"]; DiagnosticCenter pa = new Data.DiagnosticCenter(); pa = obj1.DiagnosticCenters.Where(m => m.email == email).FirstOrDefault(); DrugStoreAndDiagnosticCenterViewProfile obj = new DrugStoreAndDiagnosticCenterViewProfile(); obj.email = pa.email; obj.id = pa.id; obj.name = pa.name; obj.address = pa.address; obj.workingHour = pa.working_hour; obj.contact = pa.contact; obj.type = user; return(View(obj)); } 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()); }
public ActionResult EditProfile(DrugStoreAndDiagnosticCenterViewProfile user) { if (ModelState.IsValid) { var User = (string)Session["UserType"]; if (string.Equals(User, "DrugStore")) { var email = (string)Session["Email"]; DrugStore pa = new Data.DrugStore(); pa = obj1.DrugStores.Where(m => m.email == email).FirstOrDefault(); if (user.contact != null) { pa.contact = user.contact; } if (user.address != null) { pa.addess = user.address; } if (user.name != null) { pa.name = user.name; } if (user.workingHour != null) { pa.working_hour = user.workingHour; } if (user.new_password != null && user.current_password != null) { if (string.Equals(user.current_password, pa.password)) { pa.password = user.new_password; } else { ViewBag.a = "Enter your current password"; return(View("EditProfile")); } } obj1.DrugStores.AddOrUpdate(pa); obj1.SaveChanges(); return(RedirectToAction("ViewProfile", "DrugStoreAndDiagnosticCenterViewProfile")); } if (string.Equals(User, "DiagnosticCenter")) { var email = (string)Session["Email"]; DiagnosticCenter pa = new Data.DiagnosticCenter(); pa = obj1.DiagnosticCenters.Where(m => m.email == email).FirstOrDefault(); if (user.contact != null) { pa.contact = user.contact; } if (user.address != null) { pa.address = user.address; } if (user.name != null) { pa.name = user.name; } if (user.workingHour != null) { pa.working_hour = user.workingHour; } if (user.new_password != null && user.current_password != null) { if (string.Equals(user.current_password, pa.password)) { pa.password = user.new_password; } else { ViewBag.a = "Enter your current password"; return(View("EditProfile")); } } obj1.DiagnosticCenters.AddOrUpdate(pa); obj1.SaveChanges(); return(RedirectToAction("ViewProfile", "DrugStoreAndDiagnosticCenterViewProfile")); } } return(RedirectToAction("ViewProfile", "DrugStoreAndDiagnosticCenterViewProfile")); }