public List <LocationListItem> GetLocationListForRuleSetId(long departmentId, Guid ruleSetId, Guid SecurityToken) { if (ruleSetId == null || ruleSetId == Guid.Empty) { throw new UserInputValidationException("RuleSetId cant't be null or empty"); } if (departmentId == 0) { throw new UserInputValidationException("Department id is not valid.0 is not a valid department id."); } var locationList = m_orgService.GetLocationListByDepartmentId(departmentId, SecurityToken); var ruleSet = GetRuleSetById(ruleSetId); if (ruleSet.ExcludeOrgUnits?.Count == 0) { return(locationList); } var newlocationList = new List <LocationListItem>(); foreach (var location in locationList) { bool isAvailable = false; foreach (var _ in ruleSet.ExcludeOrgUnits.Where(unit => location.UnitGid == unit.UnitID).Select(unit => new { })) { isAvailable = true; } if (!isAvailable) { newlocationList.Add(location); } } return(newlocationList); }
public ActionResult GetLocationListByDepartmentId(long departmentId) { try { m_log.Info($"/department/location endpoint called with input department id - {departmentId}"); var wardnResponse = m_orgUnitsService.GetLocationListByDepartmentId(departmentId, m_user.SecurityToken); return(Ok(wardnResponse)); } catch (Exception e) { m_log.ErrorException("Exception thrown at GetLocationListByDepartmentId ", e); throw; } }