public ActionResult CreateRate(physician_rate physicianRate, string[] rat_shift_id, List <string> Physicians) { if (ModelState.IsValid) { for (int k = 0; k < Physicians.Count; k++) { for (int i = 0; i < rat_shift_id.Length; i++) { physicianRate.rat_phy_key = Physicians[k]; physicianRate.rat_created_by = loggedInUser.Id; physicianRate.rat_created_by_name = loggedInUser.FullName; physicianRate.rat_created_date = DateTime.Now; physicianRate.rat_range = physicianRate.rat_starting + " - " + physicianRate.rat_ending; physicianRate.rat_shift_id = rat_shift_id[i].ToInt(); physicianRate.rat_shift_name = Enum.GetName(typeof(PhysicianShifts), rat_shift_id[i].ToInt()); bool alreadyExist = _rateService.IsAlreadyExists(physicianRate.rat_phy_key, Convert.ToDateTime(physicianRate.rat_start_date), Convert.ToDateTime(physicianRate.rat_end_date), physicianRate.rat_cas_id.ToInt(), physicianRate.rat_starting.ToInt(), physicianRate.rat_ending.ToInt(), physicianRate.rat_shift_id.ToInt()); if (!alreadyExist) { var verifyRange = _rateService.IsAlreadyExistsRange(physicianRate.rat_phy_key, Convert.ToDateTime(physicianRate.rat_start_date), Convert.ToDateTime(physicianRate.rat_end_date), physicianRate.rat_cas_id.ToInt(), physicianRate.rat_starting.ToInt(), physicianRate.rat_ending.ToInt(), (int)physicianRate.rat_shift_id); if (!verifyRange) { _rateService.Create(physicianRate); } } } } return(ShowSuccessMessageOnly("Physician Productivity Rate Successfully Added", physicianRate)); } return(GetErrorResult(physicianRate)); }