public ActionResult GetWardsBySection(long sectionId) { try { m_log.Info($"/section/ward endpoint called with section id - {sectionId}"); var wardnResponse = m_orgUnitsService.GetWardListBySectionId(sectionId, m_user.SecurityToken); return(Ok(wardnResponse)); } catch (Exception e) { m_log.ErrorException("Exception thrown at GetWardsBySection ", e); throw; } }
public List <WardListItem> GetWardListForRuleSetId(long?departmentId, long?sectionId, Guid ruleSetId, Guid SecurityToken) { if (departmentId == null && sectionId == null) { throw new UserInputValidationException("Both department id and section id can't be null at same time."); } if (ruleSetId == null || ruleSetId == Guid.Empty) { throw new UserInputValidationException("RuleSetId cant't be null or empty"); } if (departmentId == 0) { throw new UserInputValidationException("Departmentid is not valid.0 is not a valid department id."); } List <WardListItem> wardList = sectionId != null ? m_orgService.GetWardListBySectionId((long)sectionId, SecurityToken) : m_orgService.GetWardListByDepartmentId((long)departmentId, SecurityToken); var ruleSet = GetRuleSetById(ruleSetId); if (ruleSet.ExcludeOrgUnits?.Count == 0) { return(wardList); } var newWardList = new List <WardListItem>(); foreach (var ward in wardList) { bool isAvailable = false; foreach (var _ in ruleSet.ExcludeOrgUnits.Where(unit => ward.UnitGid == unit.UnitID).Select(unit => new { })) { isAvailable = true; } if (!isAvailable) { newWardList.Add(ward); } } return(newWardList); }