示例#1
0
        public override DTO.ForwarderInvoiceMng.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.ForwarderInvoiceMng.EditFormData data = new DTO.ForwarderInvoiceMng.EditFormData();

            data.Data = new DTO.ForwarderInvoiceMng.ForwarderInvoice();
            data.Data.ForwarderInvoiceDetails = new List <DTO.ForwarderInvoiceMng.ForwarderInvoiceDetail>();
            data.FeeTypes = new List <DTO.Support.FeeType>();

            //try to get data
            try
            {
                if (id > 0)
                {
                    using (ForwarderInvoiceMngEntities context = CreateContext())
                    {
                        var invoice = context.ForwarderInvoiceMng_ForwarderInvoice_View.FirstOrDefault(o => o.ForwarderInvoiceID == id);
                        if (invoice == null)
                        {
                            throw new Exception("Can not found the invoice to edit");
                        }
                        data.Data = converter.DB2DTO_ForwarderInvoice(invoice);
                    }
                }
                data.FeeTypes = supportFactory.GetFeeType().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }