[HttpPost] //Then, once GET is done, public IActionResult Provider(ProviderRegisterViewModel Register) { if (ModelState.IsValid) { Login newuser = Register; //Every provider must have login regardless of specialty. _db.Logins.Add(newuser); if (Register.Specialty == "Nurse") { Nurse newNurse = Register; newNurse.LoginId = newuser.LoginId; _db.Nurses.Add(newNurse); //_db.SaveChanges(); } else if (Register.Specialty == "Anesthetist") { Anesthetist newAnesthetist = Register; newAnesthetist.LoginId = newuser.LoginId; _db.Anesthetists.Add(newAnesthetist); //_db.SaveChanges(); } else if (Register.Specialty == "Surgeon") { Surgeon newSurgeon = Register; newSurgeon.LoginId = newuser.LoginId; _db.Surgeons.Add(newSurgeon); //_db.SaveChanges(); } _db.SaveChanges(); //return RedirectToAction("Provider"); } return(RedirectToAction("Index", "Login")); }
public void Write(int pId, string avail) { var update = _db.Procedures.SingleOrDefault(p => p.ProcedureId == pId); if (update != null) { update.AnesthetistStatus = avail; _db.SaveChanges(); } }
public IActionResult AddNewRoom(OperatingRoom operatingRoom) { if (ModelState.IsValid) { operatingRoom.HospitalId = hId; _db.OperatingRooms.Add(operatingRoom); _db.SaveChanges(); } return(RedirectToAction("ViewRooms")); }
public void WriteToDb(string date, string time) { date = Convert.ToDateTime(date).ToString("yyyy-MM-dd"); OperatingRoom.DateTimeAvailable = DateTime.Parse(date + " " + time); var update = _db.OperatingRooms.SingleOrDefault(o => o.OperatingRoomId == orId); if (update != null) { update.OpRoomStatus = OperatingRoom.OpRoomStatus; update.DateTimeAvailable = OperatingRoom.DateTimeAvailable; _db.SaveChanges(); } }
public void Write(string sd, string st, string ed, string et) { DateTime date = new DateTime(); sd = Convert.ToDateTime(sd).ToString("yyyy-MM-dd"); ed = Convert.ToDateTime(ed).ToString("yyyy-MM-dd"); Procedure.ActualStart = DateTime.Parse(sd + " " + st); Procedure.ActualFinish = DateTime.Parse(ed + " " + et); foreach (var item in _db.Surgeons.ToList()) { if (item.LoginId == LoginController.LoggedInUser) { SiD = item.SurgeonId; } } foreach (var item in _db.OperatingRooms.ToList()) { if (Procedure.OperatingRoomId == item.OperatingRoomId) { Procedure.HospitalId = item.HospitalId; date = item.DateTimeAvailable; } } var update = _db.Procedures.SingleOrDefault(p => p.ProcedureId == pId); if (update != null) { update.ScheduledDateTime = date; update.SurgeonId = SiD; update.AnesthetistId = Procedure.AnesthetistId; update.OperatingRoomId = Procedure.OperatingRoomId; update.HospitalId = Procedure.HospitalId; update.ProcedureName = Procedure.ProcedureName; update.EstimatedProcedureLength = Procedure.EstimatedProcedureLength; update.Status = Procedure.Status; update.NurseId = Procedure.NurseId; update.ActualStart = Procedure.ActualStart; update.ActualFinish = Procedure.ActualFinish; _db.SaveChanges(); } }
public void Write() { DateTime date = new DateTime(); foreach (var item in _db.Surgeons.ToList()) { if (item.LoginId == LoginController.LoggedInUser) { SiD = item.SurgeonId; } } foreach (var item in _db.OperatingRooms.ToList()) { if (Procedure.OperatingRoomId == item.OperatingRoomId) { Procedure.HospitalId = item.HospitalId; date = item.DateTimeAvailable; } } _db.Procedures.Add(new Procedure() { ScheduledDateTime = date, SurgeonId = SiD, AnesthetistId = Procedure.AnesthetistId, OperatingRoomId = Procedure.OperatingRoomId, HospitalId = Procedure.HospitalId, ProcedureName = Procedure.ProcedureName, EstimatedProcedureLength = Procedure.EstimatedProcedureLength, Status = Procedure.Status, NurseId = null }); _db.SaveChanges(); }