Exemplo n.º 1
0
        public DTO.WarehouseCIMng.DataContainer GetDataContainer(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DAL.Support.DataFactory factory = new Support.DataFactory();
            //try to get data
            try
            {
                using (WarehouseCIMngEntities context = CreateContext())
                {
                    DTO.WarehouseCIMng.DataContainer dtoItem = new DTO.WarehouseCIMng.DataContainer();

                    if (id > 0)
                    {
                        WarehouseCIMng_WarehouseCI_View dbItem;
                        dbItem = context.WarehouseCIMng_WarehouseCI_View
                                 .Include("WarehouseCIMng_WarehouseCIDetail_View")
                                 .Include("WarehouseCIMng_WarehouseCIExtDetail_View")
                                 .FirstOrDefault(o => o.WarehouseCIID == id);
                        DTO.WarehouseCIMng.WarehouseCI WarehouseCIDTO = converter.DB2DTO_WarehouseCI(dbItem);
                        dtoItem.WarehouseCIData = WarehouseCIDTO;
                    }
                    else
                    {
                        dtoItem.WarehouseCIData = new DTO.WarehouseCIMng.WarehouseCI();
                        dtoItem.WarehouseCIData.WarehouseCIDetails    = new List <DTO.WarehouseCIMng.WarehouseCIDetail>();
                        dtoItem.WarehouseCIData.WarehouseCIExtDetails = new List <DTO.WarehouseCIMng.WarehouseCIExtDetail>();
                    }

                    dtoItem.Clients    = factory.GetClient().ToList();
                    dtoItem.Currency   = factory.GetCurrency().ToList();
                    dtoItem.WareHouses = factory.GetWareHouse().ToList();
                    //dtoItem.TurnOverLedgerAccount = factory.T
                    return(dtoItem);
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Warning
                };
                return(new DTO.WarehouseCIMng.DataContainer());
            }
        }