示例#1
0
        public DTO.BookingMng.EditFormData GetData(int id, int clientID, int supplierID, string season, out Library.DTO.Notification notification)
        {
            DTO.BookingMng.EditFormData data = new DTO.BookingMng.EditFormData();
            data.Data          = new DTO.BookingMng.Booking();
            data.Data.Details  = new List <DTO.BookingMng.LoadingPlan>();
            data.DeliveryTerms = new List <DTO.Support.DeliveryTerm>();
            data.Forwarders    = new List <DTO.Support.Forwarder>();
            data.MovementTerms = new List <DTO.Support.MovementTerm>();
            data.OceanFreights = new List <DTO.Support.StringCollectionItem>();
            data.PODs          = new List <DTO.Support.POD>();
            data.POLs          = new List <DTO.Support.POL>();
            notification       = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };

            //try to get data
            try
            {
                using (BookingMngEntities context = CreateContext())
                {
                    if (id == 0)
                    {
                        data.Data.ClientID   = clientID;
                        data.Data.ClientUD   = supportFactory.GetClient().FirstOrDefault(o => o.ClientID == clientID).ClientUD;
                        data.Data.SupplierID = supplierID;
                        data.Data.SupplierNM = supportFactory.GetSupplier().FirstOrDefault(o => o.SupplierID == supplierID).SupplierNM;
                        data.Data.Season     = season;
                    }
                    else
                    {
                        data.Data = converter.DB2DTO_Booking(context.BookingMng_Booking_View.Include("BookingMng_LoadingPlan_View").FirstOrDefault(o => o.BookingID == id));
                        data.Data.ConcurrencyFlag_String = Convert.ToBase64String(data.Data.ConcurrencyFlag);
                    }
                }

                data.PODs          = supportFactory.GetPOD().ToList();
                data.POLs          = supportFactory.GetPOL().ToList();
                data.Forwarders    = supportFactory.GetForwarder().ToList();
                data.DeliveryTerms = supportFactory.GetDeliveryTerm().ToList();
                data.MovementTerms = supportFactory.GetMovementTerm().ToList();
                data.OceanFreights = supportFactory.GetOceanFreight().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
            }

            return(data);
        }