public ActionResult Registered(Register model) { if (!ModelState.IsValid) { return(View(model)); } DB50Entities dbo = new DB50Entities(); Account account = new Account(); Profile profile = new Profile(); account.UserName = model.Name; account.Email = model.Email; account.Password = model.Password; dbo.Accounts.Add(account); dbo.SaveChanges(); profile.Address = model.Address; profile.ContactNumber = model.TelephoneNumber; profile.Country = model.Country; profile.Email = model.Email; profile.LicenseNumber = model.LicenseNumber; profile.TelephoneNumber = model.TelephoneNumber; profile.Type = model.type; dbo.Profiles.Add(profile); dbo.SaveChanges(); return(View(model)); }
public ActionResult AddDisease(Diseases model, int SymptomName) { DB50Entities dbo = new DB50Entities(); Disease disease = new Disease(); disease.SymptomID = SymptomName; disease.Name = model.Name; disease.Detail = model.Detail; dbo.Diseases.Add(disease); dbo.SaveChanges(); DB50Entities db = new DB50Entities(); List <string> SympName = new List <string>(); List <int> SIds = new List <int>(); foreach (Symptom d in db.Symptoms) { if (d.SymptomID != null) { SIds.Add(d.SymptomID); SympName.Add(d.SymptomName); } } ViewBag.SName = SympName; ViewBag.SIds = SIds; return(View("AddDisease")); }
public ActionResult AddSymptoms(Symptom model) { DB50Entities dbo = new DB50Entities(); Symptom symptom = new Symptom(); symptom.SymptomName = model.SymptomName; symptom.Detail = model.Detail; symptom.Reason = model.Reason; dbo.Symptoms.Add(symptom); dbo.SaveChanges(); return(View()); }
public async Task <ActionResult> Register(Register model) { string fileName = Path.GetFileNameWithoutExtension(model.ImageFile.FileName); string extension = Path.GetExtension(model.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssff") + extension; model.ImagePath = "~/img/" + fileName; fileName = Path.Combine(Server.MapPath("~/img/"), fileName); model.ImageFile.SaveAs(fileName); var ImageFile = model.ImageFile; var ImagePath = model.ImagePath; DB50Entities dbo = new DB50Entities(); Account account = new Account(); account.UserName = model.Name; account.Email = model.Email; account.Password = model.Password; account.Type = model.type; dbo.Accounts.Add(account); dbo.SaveChanges(); Profile profile = new Profile(); profile.Address = model.Address; profile.ContactNumber = model.TelephoneNumber; profile.Country = model.Country; profile.Email = model.Email; profile.LicenseNumber = model.LicenseNumber; profile.TelephoneNumber = model.TelephoneNumber; profile.Type = model.type; profile.ImagePath = ImagePath; dbo.Profiles.Add(profile); dbo.SaveChanges(); return(RedirectToAction("HomePage", "Home")); // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult AddTreatment(Treatment model, int Name, int Type) { DB50Entities dbo = new DB50Entities(); Treatment treatment = new Treatment(); treatment.DiseaseID = Name; treatment.CategoryID = Type; treatment.TreatmentName = model.TreatmentName; treatment.Detail = model.Detail; dbo.Treatments.Add(treatment); dbo.SaveChanges(); return(RedirectToAction("AddTreatment")); }
public ActionResult DeleteTreatment(int id, Treatment model) { try { DB50Entities db = new DB50Entities(); var ToDelete = db.Treatments.Single(x => x.TreatmentID == id); db.Treatments.Remove(ToDelete); db.SaveChanges(); return(View("~/Views/Disease/AddDisease.cshtml")); } catch { return(View()); } }
public ActionResult DeleteDisease(int id, Disease obj) { try { DB50Entities db = new DB50Entities(); var ToDelete = db.Diseases.Single(x => x.DiseaseID == id); db.Diseases.Remove(ToDelete); db.SaveChanges(); return(View("AddDisease")); } catch { return(View()); } }
public ActionResult DeleteSymptoms(int id, Symptom obj) { try { DB50Entities db = new DB50Entities(); var ToDelete = db.Symptoms.Single(x => x.SymptomID == id); db.Symptoms.Remove(ToDelete); db.SaveChanges(); return(View("AddSymptoms")); } catch { return(View()); } }
public ActionResult UpdateTreatment(Treatment model, int id) { try { using (DB50Entities db = new DB50Entities()) { db.Treatments.Find(id).TreatmentName = model.TreatmentName; db.Treatments.Find(id).Detail = model.Detail; db.SaveChanges(); } return(View("~/Views/Disease/AddDisease.cshtml")); } catch { return(View()); } }
public ActionResult UpdateDisease(Disease obj, int id) { try { using (DB50Entities db = new DB50Entities()) { db.Diseases.Find(id).Name = obj.Name; db.Diseases.Find(id).Detail = obj.Detail; db.SaveChanges(); } return(View("AddDisease")); } catch { return(View()); } }
public ActionResult UpdateSymptoms(Symptom obj, int id) { try { using (DB50Entities db = new DB50Entities()) { db.Symptoms.Find(id).SymptomName = obj.SymptomName; db.Symptoms.Find(id).Detail = obj.Detail; db.Symptoms.Find(id).Reason = obj.Reason; db.SaveChanges(); } return(View("AddSymptoms")); } catch { return(View()); } }
public ActionResult CreatePassword(CreatePassword model) { DB50Entities db = new DB50Entities(); foreach (var person in db.Accounts.ToList()) { if (person.Email == model.Email) { if (model.NewPassword == model.ConfirmPassword) { person.Password = model.NewPassword; db.Accounts.Find(person.Id).Password = person.Password; db.SaveChanges(); return(RedirectToAction("Login", "Account")); } } } return(View()); }
public ActionResult ChangePassword(Password pass) { DB50Entities db = new DB50Entities(); foreach (var user in db.Accounts.ToList()) { if (user.Email == Session["Email"].ToString()) { if (user.Password == pass.OldPassword) { if (pass.NewPassword == pass.ConfirmPassword) { db.Accounts.Find(user.Id).Password = pass.NewPassword; db.SaveChanges(); return(RedirectToAction("UserProfile", "Manage")); } } } } return(View()); }