public void Create(facility_physician entity) { entity.fap_start_date = DateTime.Now.ToEST(); _unitOfWork.FacilityPhysicianRepository.Insert(entity); _unitOfWork.Save(); _unitOfWork.Commit(); }
public bool Delete(facility_physician entity) { _unitOfWork.FacilityPhysicianRepository.Delete(entity.fap_key); _unitOfWork.Save(); _unitOfWork.Commit(); return(true); }
public bool IsAlreadyExists(facility_physician entity) { return(_unitOfWork.FacilityPhysicianRepository.Query() .Where(m => m.fap_is_active) .Where(m => m.fap_fac_key == entity.fap_fac_key) .Where(m => m.fap_user_key == entity.fap_user_key) .Where(m => m.fap_key != entity.fap_key) .Any()); }
public void Edit(facility_physician entity, bool commitChange = true) { var facilityPhsycian = _unitOfWork.FacilityPhysicianRepository.Query().Where(x => x.fap_key == entity.fap_key).FirstOrDefault(); if (facilityPhsycian != null) { facilityPhsycian.fap_UserName = entity.fap_UserName; facilityPhsycian.fap_is_on_boarded = entity.fap_is_on_boarded; facilityPhsycian.fap_onboarded_by = entity.fap_onboarded_by; facilityPhsycian.fap_onboarded_date = DateTime.Now.ToEST(); facilityPhsycian.fap_onboarded_by_name = entity.fap_onboarded_by_name; facilityPhsycian.fap_onboarded_date = DateTime.Now; facilityPhsycian.fap_hide = entity.fap_hide; _unitOfWork.FacilityPhysicianRepository.Update(facilityPhsycian); if (commitChange) { _unitOfWork.Save(); _unitOfWork.Commit(); } } }
public ActionResult SaveFacility(facility_physician model, bool FacilityView) { try { if (ModelState.IsValid) { if (ModelState.IsValid) { if (_facilityPhysicianService.IsAlreadyExists(model)) { if (FacilityView) { ModelState.AddModelError("", "Facility already exists"); } else { ModelState.AddModelError("", "physician already exists"); } } if (model.fap_key > 0) { var dbModel = _facilityPhysicianService.GetDetails(model.fap_key); var chk_value_path = model.fap_Array_path; if (chk_value_path == null) { model.fap_Array_path = "[]"; } var items = Newtonsoft.Json.JsonConvert.DeserializeObject <List <facility_physician> >(model.fap_Array_path); if (items.Equals(0)) { } else { _facilityPhysicianService.Save(); _facilityPhysicianService.Commit(); var ssss = UpdatePhysicians(items, model); foreach (var item in ssss) { _facilityPhysicianService.Edit(item, false); _facilityPhysicianService.Save(); _facilityPhysicianService.Commit(); } //_facilityPhysicianService.EditForMultiple(ssss); } #region handling change log var changes = _facilityPhysicianService.GetChangeTrackset("fap_created_date"); if (changes.Count() > 0) { AddChangeLog(changes, model.fap_key.ToString(), EntityTypes.Credentials); } #endregion } else { model.fap_created_by = User.Identity.GetUserId(); model.fap_is_active = true; model.fap_created_date = DateTime.Now.ToEST(); var items = Newtonsoft.Json.JsonConvert.DeserializeObject <List <facility_physician> >(model.fap_UserName); if (items.Equals(0)) { } else { var ssss = UpdatePhysicians(items, model); _facilityPhysicianService.EditForMultiple(ssss); } if (model.fap_is_on_boarded) { model.fap_onboarded_by = User.Identity.GetUserId(); model.fap_onboarded_date = DateTime.Now.ToEST(); model.fap_onboarded_by_name = loggedInUser.FullName; } if (model.fap_is_override) { model.fap_override_start = model.fap_created_date; } _facilityPhysicianService.Create(model); } return(Json(new { success = true })); } } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(Json(new { success = false, data = string.Join("<br/>", this.GetModalErrors().Values) })); }
private List <facility_physician> UpdatePhysicians(List <facility_physician> existingEntries, facility_physician model) { List <facility_physician> updatedPhysicians = new List <facility_physician>(); var exist_value = model.fap_Array_path; if (exist_value == "[]") { facility_physician _facility_Physician = new facility_physician(); var dbModel = _facilityPhysicianService.GetDetails(model.fap_key); if (dbModel.fap_is_on_boarded != model.fap_is_on_boarded) { _facility_Physician.fap_onboarded_by = User.Identity.GetUserId(); _facility_Physician.fap_onboarded_date = DateTime.Now.ToEST(); _facility_Physician.fap_onboarded_by_name = loggedInUser.FullName; } _facility_Physician.fap_is_active = true; _facility_Physician.fap_modified_by = User.Identity.GetUserId(); _facility_Physician.fap_modified_by_name = loggedInUser.FullName; _facility_Physician.fap_modified_date = DateTime.Now.ToEST(); _facility_Physician.fap_Password_BY = User.Identity.GetUserId(); _facility_Physician.fap_Password_Date = DateTime.Now.ToEST(); _facility_Physician.fap_onboarded_by = User.Identity.GetUserId(); _facility_Physician.fap_onboarded_date = DateTime.Now.ToEST(); _facility_Physician.fap_onboarded_by_name = loggedInUser.FullName; _facility_Physician.fap_is_on_boarded = model.fap_is_on_boarded; _facility_Physician.fap_key = dbModel.fap_key; _facility_Physician.fap_UserName = dbModel.fap_UserName; _facility_Physician.fap_Password = dbModel.fap_Password; _facility_Physician.fap_created_by = dbModel.fap_created_by; _facility_Physician.fap_fac_key = dbModel.fap_fac_key; _facility_Physician.fap_user_key = dbModel.fap_user_key; _facility_Physician.fap_created_date = dbModel.fap_created_date; _facility_Physician.fap_Credentials_confirmed_date = dbModel.fap_Credentials_confirmed_date; _facility_Physician.fap_date_assigned = dbModel.fap_date_assigned; _facility_Physician.fap_end_date = dbModel.fap_end_date; _facility_Physician.fap_onboarding_complete_provider_active_date = dbModel.fap_onboarding_complete_provider_active_date; _facility_Physician.fap_preapp_receive_date = dbModel.fap_preapp_receive_date; _facility_Physician.fap_preapp_request_date = dbModel.fap_preapp_request_date; _facility_Physician.fap_preapp_submitted_date = dbModel.fap_preapp_submitted_date; _facility_Physician.fap_start_date = dbModel.fap_start_date; _facility_Physician.fap_vcaa_date = dbModel.fap_vcaa_date; _facility_Physician.fap_is_active = dbModel.fap_is_active; _facility_Physician.fap_is_hide_pending_onboarding = dbModel.fap_is_hide_pending_onboarding; _facility_Physician.fap_created_by = dbModel.fap_created_by; _facility_Physician.fap_created_by_name = dbModel.fap_created_by_name; _facility_Physician.fap_created_date = dbModel.fap_created_date; _facility_Physician.fap_Credentials_confirmed_date = dbModel.fap_Credentials_confirmed_date; _facility_Physician.fap_credential_specialist = dbModel.fap_credential_specialist; _facilityPhysicianService.Edit(_facility_Physician, false); _facilityPhysicianService.Save(); _facilityPhysicianService.Commit(); } else { var dbModelForPhysicin = _facilityPhysicianService.GetDetails(model.fap_key); facility_physician facility_Physicians = new facility_physician(); if (dbModelForPhysicin.fap_is_on_boarded != model.fap_is_on_boarded) { facility_Physicians.fap_onboarded_by = User.Identity.GetUserId(); facility_Physicians.fap_onboarded_date = DateTime.Now.ToEST(); facility_Physicians.fap_onboarded_by_name = loggedInUser.FullName; facility_Physicians.fap_is_on_boarded = model.fap_is_on_boarded; facility_Physicians.fap_modified_by = User.Identity.GetUserId(); facility_Physicians.fap_modified_by_name = loggedInUser.FullName; facility_Physicians.fap_modified_date = DateTime.Now.ToEST(); facility_Physicians.fap_Password_BY = User.Identity.GetUserId(); facility_Physicians.fap_Password_Date = DateTime.Now.ToEST(); if (model.fap_is_override) { facility_Physicians.fap_override_start = model.fap_modified_date; } else { facility_Physicians.fap_override_start = null; facility_Physicians.fap_override_hours = null; } if (facility_Physicians != null) { facility_Physicians.fap_key = model.fap_key; facility_Physicians.fap_UserName = dbModelForPhysicin.fap_UserName; facility_Physicians.fap_Password = dbModelForPhysicin.fap_Password; facility_Physicians.fap_created_by = dbModelForPhysicin.fap_created_by; facility_Physicians.fap_fac_key = dbModelForPhysicin.fap_fac_key; facility_Physicians.fap_user_key = dbModelForPhysicin.fap_user_key; facility_Physicians.fap_created_date = dbModelForPhysicin.fap_created_date; facility_Physicians.fap_Credentials_confirmed_date = dbModelForPhysicin.fap_Credentials_confirmed_date; facility_Physicians.fap_date_assigned = dbModelForPhysicin.fap_date_assigned; facility_Physicians.fap_end_date = dbModelForPhysicin.fap_end_date; facility_Physicians.fap_onboarding_complete_provider_active_date = dbModelForPhysicin.fap_onboarding_complete_provider_active_date; facility_Physicians.fap_preapp_receive_date = dbModelForPhysicin.fap_preapp_receive_date; facility_Physicians.fap_preapp_request_date = dbModelForPhysicin.fap_preapp_request_date; facility_Physicians.fap_preapp_submitted_date = dbModelForPhysicin.fap_preapp_submitted_date; facility_Physicians.fap_start_date = dbModelForPhysicin.fap_start_date; facility_Physicians.fap_vcaa_date = dbModelForPhysicin.fap_vcaa_date; facility_Physicians.fap_is_active = dbModelForPhysicin.fap_is_active; facility_Physicians.fap_is_hide_pending_onboarding = dbModelForPhysicin.fap_is_hide_pending_onboarding; facility_Physicians.fap_created_by = dbModelForPhysicin.fap_created_by; facility_Physicians.fap_created_by_name = dbModelForPhysicin.fap_created_by_name; facility_Physicians.fap_created_date = dbModelForPhysicin.fap_created_date; facility_Physicians.fap_Credentials_confirmed_date = dbModelForPhysicin.fap_Credentials_confirmed_date; facility_Physicians.fap_credential_specialist = dbModelForPhysicin.fap_credential_specialist; _facilityPhysicianService.Edit(facility_Physicians, false); _facilityPhysicianService.Save(); _facilityPhysicianService.Commit(); } } foreach (var item in existingEntries) { var dbModel = _facilityPhysicianService.GetDetailsByFacKey(item.fap_fac_key, item.fap_user_key); // var _facility_Physician = _facilityPhysicianService.GetDetailsByFacKey(item.fap_fac_key, item.fap_user_key); facility_physician _facility_Physician = new facility_physician(); _facility_Physician.fap_is_active = true; _facility_Physician.fap_onboarded_by = User.Identity.GetUserId(); _facility_Physician.fap_onboarded_date = DateTime.Now.ToEST(); _facility_Physician.fap_onboarded_by_name = loggedInUser.FullName; _facility_Physician.fap_modified_by = User.Identity.GetUserId(); _facility_Physician.fap_modified_by_name = loggedInUser.FullName; _facility_Physician.fap_modified_date = DateTime.Now.ToEST(); _facility_Physician.fap_Password_BY = User.Identity.GetUserId(); _facility_Physician.fap_Password_Date = DateTime.Now.ToEST(); _facility_Physician.fap_is_on_boarded = dbModel.fap_is_on_boarded; if (model.fap_is_override) { _facility_Physician.fap_override_start = model.fap_modified_date; } else { _facility_Physician.fap_override_start = null; _facility_Physician.fap_override_hours = null; } if (_facility_Physician != null) { _facility_Physician.fap_key = dbModel.fap_key; _facility_Physician.fap_UserName = item.fap_UserName; _facility_Physician.fap_Password = item.fap_Password; _facility_Physician.fap_created_by = dbModel.fap_created_by; _facility_Physician.fap_fac_key = dbModel.fap_fac_key; _facility_Physician.fap_user_key = dbModel.fap_user_key; _facility_Physician.fap_created_date = dbModel.fap_created_date; _facility_Physician.fap_Credentials_confirmed_date = dbModel.fap_Credentials_confirmed_date; _facility_Physician.fap_date_assigned = dbModel.fap_date_assigned; _facility_Physician.fap_end_date = dbModel.fap_end_date; _facility_Physician.fap_onboarding_complete_provider_active_date = dbModel.fap_onboarding_complete_provider_active_date; _facility_Physician.fap_preapp_receive_date = dbModel.fap_preapp_receive_date; _facility_Physician.fap_preapp_request_date = dbModel.fap_preapp_request_date; _facility_Physician.fap_preapp_submitted_date = dbModel.fap_preapp_submitted_date; _facility_Physician.fap_start_date = dbModel.fap_start_date; _facility_Physician.fap_vcaa_date = dbModel.fap_vcaa_date; _facility_Physician.fap_is_active = dbModel.fap_is_active; _facility_Physician.fap_is_hide_pending_onboarding = dbModel.fap_is_hide_pending_onboarding; _facility_Physician.fap_created_by = dbModel.fap_created_by; _facility_Physician.fap_created_by_name = dbModel.fap_created_by_name; _facility_Physician.fap_created_date = dbModel.fap_created_date; _facility_Physician.fap_Credentials_confirmed_date = dbModel.fap_Credentials_confirmed_date; _facility_Physician.fap_credential_specialist = dbModel.fap_credential_specialist; updatedPhysicians.Add(_facility_Physician); } } } return(updatedPhysicians); }
public ActionResult Edit_Facility_Physician(int?fap_key_values, bool chk_value) { try { facility_physician model = new facility_physician(); var value_key = fap_key_values ?? 0; var dbModel = _facilityPhysicianService.GetDetails(value_key); if (dbModel.fap_is_on_boarded == chk_value) { model.fap_key = value_key; model.fap_is_on_boarded = false; model.fap_onboarded_by = User.Identity.GetUserId(); model.fap_onboarded_date = DateTime.Now.ToEST(); model.fap_onboarded_by_name = loggedInUser.FullName; model.fap_created_by = User.Identity.GetUserId(); model.fap_user_key = dbModel.fap_user_key; model.fap_created_date = DateTime.Now.ToEST(); model.fap_fac_key = dbModel.fap_fac_key; model.fap_start_date = dbModel.fap_start_date; model.fap_end_date = dbModel.fap_end_date; model.fap_UserName = dbModel.fap_UserName; model.fap_Password = dbModel.fap_Password; if (model.fap_is_override) { model.fap_override_start = model.fap_modified_date; } else { model.fap_override_start = null; model.fap_override_hours = null; } return(Json(false)); } else { model.fap_key = value_key; model.fap_is_active = true; model.fap_is_on_boarded = chk_value; model.fap_modified_by = User.Identity.GetUserId(); model.fap_modified_by_name = loggedInUser.FullName; model.fap_modified_date = DateTime.Now.ToEST(); model.fap_created_by = User.Identity.GetUserId(); model.fap_user_key = dbModel.fap_user_key; model.fap_created_date = DateTime.Now.ToEST(); model.fap_start_date = dbModel.fap_start_date; model.fap_end_date = dbModel.fap_end_date; model.fap_fac_key = dbModel.fap_fac_key; model.fap_UserName = dbModel.fap_UserName; model.fap_Password = dbModel.fap_Password; model.fap_onboarded_by = User.Identity.GetUserId(); model.fap_onboarded_date = DateTime.Now.ToEST(); model.fap_onboarded_by_name = loggedInUser.FullName; if (model.fap_is_override) { model.fap_override_start = model.fap_modified_date; } else { model.fap_override_start = null; model.fap_override_hours = null; } } _facilityPhysicianService.Edit(model, false); _facilityPhysicianService.Save(); _facilityPhysicianService.Commit(); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); ModelState.AddModelError("", "Error! Please try again."); } return(Json(new { success = true })); }