public void DeleteClinic(int ClinicInfoId) { DoctorClinicInformation DoctorClinic = DBcontext.DoctorsClinicInfos.Find(ClinicInfoId); DBcontext.DoctorsClinicInfos.Remove(DoctorClinic); }
public void InsertClinic(DoctorClinicInformation doctorClinic) { DBcontext.DoctorsClinicInfos.Add(doctorClinic); }
public void UpdateClinic(DoctorClinicInformation doctorClinic) { DBcontext.Entry(doctorClinic).State = EntityState.Modified; }
public ActionResult Create(DoctorClinicInformationViewModel _doctorClinicVM) { try { // ModelState.Clear(); // Cleare Model state if (ModelState.IsValid) { _doctorClinicVM.LoginId = Convert.ToInt32(Session["Doctor"]); var existingUser = db.DoctorsClinicInfos.FirstOrDefault(u => u.LoginId == _doctorClinicVM.LoginId); int Id = (Convert.ToInt32(Session["Doctor"])); if (ReferenceEquals(existingUser, null)) { var newClinic = new DoctorClinicInformation(); newClinic.ClinicName = _doctorClinicVM.ClinicName; newClinic.ClinicAddress = _doctorClinicVM.ClinicAddress; newClinic.ClinicPhoneNo = _doctorClinicVM.ClinicPhoneNo; newClinic.ClinicFees = _doctorClinicVM.ClinicFees; newClinic.Country = _doctorClinicVM.Country; newClinic.State = _doctorClinicVM.State; newClinic.City = _doctorClinicVM.City; newClinic.ZipCode = _doctorClinicVM.ZipCode; newClinic.ClinicServices = _doctorClinicVM.ClinicServices; newClinic.AwardsAndRecognization = _doctorClinicVM.AwardsAndRecognization; newClinic.AboutClinic = _doctorClinicVM.AboutClinic; newClinic.InactiveFlag = "N"; newClinic.CreatedByID = 1; // for now we add 1 later we change newClinic.CreatedDate = DateTime.Now; newClinic.ModifiedByID = 1; // for now we add 1 later we change newClinic.ModifiedDate = DateTime.Now; newClinic.LoginId = Id; doctorClinicRepository.InsertClinic(newClinic); doctorClinicRepository.Save(); @TempData["SuccessMessage"] = "Succsessfully save data"; } else { existingUser.ClinicName = _doctorClinicVM.ClinicName; existingUser.ClinicAddress = _doctorClinicVM.ClinicAddress; existingUser.ClinicPhoneNo = _doctorClinicVM.ClinicPhoneNo; existingUser.ClinicFees = _doctorClinicVM.ClinicFees; existingUser.Country = _doctorClinicVM.Country; existingUser.State = _doctorClinicVM.State; existingUser.City = _doctorClinicVM.City; existingUser.ZipCode = _doctorClinicVM.ZipCode; existingUser.ClinicServices = _doctorClinicVM.ClinicServices; existingUser.AwardsAndRecognization = _doctorClinicVM.AwardsAndRecognization; existingUser.AboutClinic = _doctorClinicVM.AboutClinic; existingUser.InactiveFlag = "N"; existingUser.CreatedByID = 1; // for now we add 1 later we change existingUser.CreatedDate = DateTime.Now; existingUser.ModifiedByID = 1; // for now we add 1 later we change existingUser.ModifiedDate = DateTime.Now; existingUser.LoginId = Id; //Update if already exit doctorClinicRepository.UpdateClinic(existingUser); doctorClinicRepository.Save(); @TempData["SuccessMessage"] = "Succsessfully Update data"; } } } catch (Exception) { //ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator."); @TempData["Message"] = "Unable to save changes. Try again, and if the problem persists contact your system administrator."; } return(RedirectToAction("Create")); }