public async Task <ActionResult> Subscribe(LoyaltySubscribeVM model) { if (ModelState.IsValid) { db.Loyalties.Add(new Loyalty { Loyalty_Points = 0, PatientId = model.PatientId, Registered = DateTime.Now }); UpdatePatient(model); await db.SaveChangesAsync(); Session["UserName"] = ""; Session["IsLoyal"] = false; Session["id"] = ""; Session["Title"] = ""; ViewBag.Message = ""; return(RedirectToAction("Congratulations")); } return(View(model)); }
public void UpdatePatient(LoyaltySubscribeVM model) { Patient patient = db.Patients.Find(model.PatientId); patient.isLoyal = true; db.Entry(patient).State = EntityState.Modified; }