public bool SaveCostCodeIds(List <long> CostCodeIds, long LocationId, long UserId) { bool IsSaved = false; string action = "I"; string result = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); List <string> CostCodedata = new List <string>(); try { if (CostCodeIds.Count > 0) { foreach (var item in CostCodeIds) { var ChildCostCode = _workorderems.CostCodes.Where(x => x.CCD_CostCode == item).FirstOrDefault(); if (ChildCostCode == null) { } else { var saveCostCodeId = _workorderems.spSetCostCodeLocationMapping(action, LocationId, ChildCostCode.CCD_CCM_CostCode, item); IsSaved = true; CostCodedata.Add(ChildCostCode.CCD_Description); } } } var locationName = _workorderems.LocationMasters.Where(x => x.LocationId == LocationId && x.IsDeleted == false).FirstOrDefault(); result = string.Join(",", CostCodedata.ToArray()); #region Save DAR objDAR.ActivityDetails = DarMessage.AllocateCostCodeForLocation(locationName.LocationName, result); objDAR.TaskType = (long)TaskTypeCategory.AllocateCostcode; objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.LocationId = LocationId; objDAR.DeletedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public bool SaveCostCodeIds(List<long> CostCodeIds, long LocationId)", "Exception While Saving Cost Code to database", LocationId); throw; } return(IsSaved); }