/// <summary> /// Get list of department by locations /// </summary> /// <param name="IsShiftRequestRequired"></param> /// <returns></returns> public List <Department> GetByLocations(List <int> locationIds) { List <Department> departments = new List <Department>(); var query = string.Empty; if (locationIds != null && locationIds.Count > 0 && !locationIds.Contains(0)) { var locationFilter = CommonHelper.BuildFilterCommonMultiLocations(locationIds); if (!string.IsNullOrEmpty(locationFilter)) { query = $"{locationFilter}"; } } departments = GetByQuery($"<Where>{query}</Where>", string.Empty); return(departments); }
/// <summary> /// Get list of department by IsShiftRequestRequired /// </summary> /// <param name="IsShiftRequestRequired"></param> /// <returns></returns> public List <Department> GetByShiftRequestRequired(bool IsShiftRequestRequired, List <int> locationIds) { List <Department> departments = new List <Department>(); string boolString = IsShiftRequestRequired ? "1" : "0"; string query = $"<Eq><FieldRef Name='IsShiftRequestRequired' /><Value Type='Boolean'>{boolString}</Value></Eq>"; if (locationIds != null && locationIds.Count > 0 && !locationIds.Contains(0)) { var locationFilter = CommonHelper.BuildFilterCommonMultiLocations(locationIds); if (!string.IsNullOrEmpty(locationFilter)) { query = $"<And>{query}{locationFilter}</And>"; } } departments = GetByQuery($"<Where>{query}</Where>", string.Empty); return(departments); }
/// CALL URL : _vti_bin/Services/Department/DepartmentService.svc/GetDepartments/vi-VN public List <DepartmentInfo> GetDepartments(string languageCode, string locationIds) { var listResult = new List <DepartmentInfo>(); try { List <Biz.Models.Department> departmentEntities = new List <Biz.Models.Department>(); List <int> locationCollection = locationIds.SplitStringOfLocations().ConvertAll(e => Convert.ToInt32(e)); if (locationCollection != null && !locationCollection.Contains(0)) { var locationFilter = CommonHelper.BuildFilterCommonMultiLocations(locationCollection); if (!string.IsNullOrEmpty(locationFilter)) { departmentEntities = _departmentDal.GetByQuery($"<Where>{locationFilter}</Where>", string.Empty); } } else { departmentEntities = _departmentDal.GetAll(); } foreach (var departmentEntity in departmentEntities) { listResult.Add(new DepartmentInfo { Id = departmentEntity.ID, DepartmentName = languageCode == "vi-VN" ? departmentEntity.VietnameseName : departmentEntity.Name }); } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Service - GetDepartmentByIdLanguageCode fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } return(listResult); }
public List <Department> GetDepartmentsByLocation(List <int> locationIds) { var listResult = new List <Department>(); try { if (locationIds == null || (locationIds != null && locationIds.Count == 0) || (locationIds != null && locationIds.Contains(0))) { listResult = this.GetAll(); } else { var locationFilter = CommonHelper.BuildFilterCommonMultiLocations(locationIds); if (!string.IsNullOrEmpty(locationFilter)) { listResult = GetByQuery($"<Where>{locationFilter}</Where>", string.Empty); } } } catch { } return(listResult); }