public bool IsTypeAlreadyExists(physician_status entity) { return(_unitOfWork.PhysicianStatusRepository.Query() .Where(m => m.phs_name.ToLower().Trim() == entity.phs_name.ToLower().Trim()) .Where(m => m.phs_key != entity.phs_key) .Any()); }
public void Create(physician_status entity) { #region Removing IsDefault check from existing records in case of IsDefault true if (entity.phs_is_default) { var removeDefaultCheck = _unitOfWork.PhysicianStatusRepository .Query() .Where(m => m.phs_is_default) .ToList(); removeDefaultCheck.ForEach(m => { m.phs_is_default = false; }); } #endregion #region Finding Sort Order Value var caseTypes = _unitOfWork.PhysicianStatusRepository.Query(); int sortOrder = caseTypes.Count() > 0 ? caseTypes.Max(m => m.phs_sort_order) : 0; entity.phs_sort_order = (sortOrder + 1); #endregion _unitOfWork.PhysicianStatusRepository.Insert(entity); _unitOfWork.Save(); _unitOfWork.Commit(); }
public bool Delete(physician_status entity) { if (!entity.AspNetUsers.Any()) { _unitOfWork.PhysicianStatusRepository.Delete(entity.phs_key); _unitOfWork.Save(); _unitOfWork.Commit(); return(true); } return(false); }
// GET: physician_status/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } physician_status physician_status = _PhysicianStatusService.GetDetails(id.Value); if (physician_status == null) { return(HttpNotFound()); } return(GetViewResult(physician_status)); }
public ActionResult Create([Bind(Exclude = "phs_key, phs_sort_order")] physician_status physician_status) { if (ModelState.IsValid) { if (physician_status.phs_move_status_key.HasValue && physician_status.phs_move_threshhold_time == null) { ModelState.AddModelError("phs_move_threshhold_time", "Select the status move time"); } if (physician_status.phs_move_status_key == null && physician_status.phs_move_threshhold_time.HasValue) { ModelState.AddModelError("phs_move_status_key", "Select Move to State"); } if (_PhysicianStatusService.IsTypeAlreadyExists(physician_status)) { ModelState.AddModelError("phs_name", $"Type {physician_status.phs_name} already exists"); } if (_PhysicianStatusService.IsColorCodeAlreadyExists(physician_status)) { ModelState.AddModelError("phs_color_code", $"Color {physician_status.phs_color_code} is already assigned"); } if (ModelState.IsValid) // re validating model after custom validations { physician_status.phs_created_by = User.Identity.GetUserId(); physician_status.phs_created_date = DateTime.Now.ToEST(); _PhysicianStatusService.Create(physician_status); #region handling snooze data var jsonData = Newtonsoft.Json.JsonConvert.DeserializeObject <List <physician_status_snooze_option> >(Request.Params["hdnSnoozeJson"]); if (jsonData.Count > 0) { jsonData.ForEach(m => { m.pso_created_by = loggedInUser.Id; m.pso_created_by_name = loggedInUser.FullName; }); } _PhysicianStatusService.SaveStatusSnoozeOptions(physician_status.phs_key, jsonData); #endregion return(GetSuccessResult()); } } return(GetErrorResult(physician_status)); }
public void Edit(physician_status entity) { #region Removing IsDefault check from existing records in case of IsDefault true if (entity.phs_is_default) { var removeDefaultCheck = _unitOfWork.PhysicianStatusRepository .Query() .Where(m => m.phs_is_default) .Where(m => m.phs_key != entity.phs_key) .ToList(); removeDefaultCheck.ForEach(m => { m.phs_is_default = false; }); } #endregion _unitOfWork.PhysicianStatusRepository.Update(entity); _unitOfWork.Save(); _unitOfWork.Commit(); }