// // CUSTOM FUNCTION HERE // public DTO.SupportFormData GetInitData(out Library.DTO.Notification notification) { SupportFormData data = new SupportFormData(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; data.CompanyDTOs = new List <CompanyDTO>(); try { using (AnnualLeaveCalendarMngEntities context = CreateContext()) { data.CompanyDTOs = converter.DB2DTO_CompanyDTOs(context.AnnualLeaveCalendarMng_Company_View.ToList()); } } catch (Exception ex) { notification = new Library.DTO.Notification() { Message = ex.Message, Type = Library.DTO.NotificationType.Error }; } return(data); }
public override DTO.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; SearchFormData data = new SearchFormData(); data.Data = new List <AnnualLeaveCalendarSearchResultDTO>(); totalRows = 0; //try to get data try { using (AnnualLeaveCalendarMngEntities context = CreateContext()) { string MeetingLocations = null; int? type = null; int Month = Convert.ToInt32(filters["month"]); int Year = Convert.ToInt32(filters["year"]); if (filters.ContainsKey("locations") && !string.IsNullOrEmpty(filters["locations"].ToString())) { MeetingLocations = string.Empty; foreach (int locationID in Newtonsoft.Json.JsonConvert.DeserializeObject <int[]>(filters["locations"].ToString().Replace("'", "''"))) { if (string.IsNullOrEmpty(MeetingLocations) && locationID != 5) { MeetingLocations += locationID.ToString(); } else if (string.IsNullOrEmpty(MeetingLocations) && locationID == 5) { MeetingLocations += locationID.ToString(); type = locationID; } else if (locationID != 5) { MeetingLocations += "," + locationID.ToString();; } else if (locationID == 5) { type = locationID; } } } data.Data = converter.DB2DTO_SearchResultDTOs(context.AnnualLeaveCalendarMng_function_SearchResult(MeetingLocations, Month, Year, type).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }