public async Task <string> CreateConsultation(CreateCosulationModel model) { if (ModelState.IsValid) { Consultation_v2 dto = new Consultation_v2 { PatientName = model.PatientName, Notes = model.Notes, Symptoms = model.Symptoms, Diagnosis = model.Diagnosis, AppointmentDate = model.AppointmentDate, AppointmentID = model.AppointmentID, PatientId = model.PatientId }; db.Consultation_V2s.Add(dto); Appointment appointment = db.Appointments.Where(a => a.AppointmentID.Equals(model.AppointmentID)).FirstOrDefault(); appointment.Complete = true; db.Entry(appointment).State = EntityState.Modified; await db.SaveChangesAsync(); return("Success"); } TempData["Error"] = "An error has occured. Try again"; return("Error"); }
public async Task <ActionResult> Create(CreateCosulationModel model) { if (ModelState.IsValid) { Consultation_v2 dto = new Consultation_v2 { PatientName = model.PatientName, Notes = model.Notes, Symptoms = model.Symptoms, Diagnosis = model.Diagnosis, AppointmentDate = model.AppointmentDate, AppointmentID = model.AppointmentID, PatientId = model.PatientId }; db.Consultation_V2s.Add(dto); Appointment appointment = db.Appointments.Where(a => a.AppointmentID.Equals(model.AppointmentID)).FirstOrDefault(); appointment.Complete = true; db.Entry(appointment).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }