public DTO.PLCMng.InitFormData GetInitData(int userId, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; DTO.PLCMng.InitFormData data = new DTO.PLCMng.InitFormData(); data.Factories = new List <DTO.Support.Factory>(); data.Items = new List <DTO.PLCMng.ItemForCreatePLC>(); //try to get data try { data.Factories = supportFactory.GetAuthorizedFactories(userId).ToList(); using (PLCMngEntities context = CreateContext()) { List <int> factoryIds = new List <int>(); factoryIds.AddRange(data.Factories.Select(o => o.FactoryID).ToList()); data.Items = converter.DB2DTO_ItemForCreatePLCList(context.PLCMng_ItemForCreatePLC_View.Where(o => o.FactoryID.HasValue && factoryIds.Contains(o.FactoryID.Value)).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public IHttpActionResult GetInitData() { BLL.PLCMng bll = new BLL.PLCMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext)); Library.DTO.Notification notification; DTO.PLCMng.InitFormData data = bll.GetInitData(ControllerContext.GetAuthUserId(), out notification); return(Ok(new Library.DTO.ReturnData <DTO.PLCMng.InitFormData>() { Data = data, Message = notification, TotalRows = 0 })); }