public DTO.QuotationMng.InitFormData GetInitData(int userId, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; DTO.QuotationMng.InitFormData data = new DTO.QuotationMng.InitFormData(); data.Factories = new List <DTO.Support.Factory>(); data.Orders = new List <DTO.QuotationMng.FactoryOrderSearchResult>(); data.Seasons = new List <DTO.Support.Season>(); //try to get data try { Task task1 = Task.Factory.StartNew(() => { data.Seasons = supportFactory.GetSeason().ToList(); }); Task task2 = Task.Factory.StartNew(() => { data.Factories = supportFactory.GetAuthorizedFactories(userId).ToList(); using (QuotationMngEntities context = CreateContext()) { List <int> factoryIds = new List <int>(); factoryIds.AddRange(data.Factories.Select(o => o.FactoryID).ToList()); data.Orders = converter.DB2DTO_FactoryOrder(context.QuotationMng_FactoryOrderSearchResult_View.Where(o => o.FactoryID.HasValue && factoryIds.Contains(o.FactoryID.Value)).OrderBy(o => o.ProductionStatus).ToList()); } }); Task.WaitAll(task1, task2); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public IHttpActionResult GetInitData() { BLL.QuotationMng bll = new BLL.QuotationMng(); Library.DTO.Notification notification; DTO.QuotationMng.InitFormData data = bll.GetInitData(ControllerContext.GetAuthUserId(), out notification); return(Ok(new Library.DTO.ReturnData <DTO.QuotationMng.InitFormData>() { Data = data, Message = notification, TotalRows = 0 })); }