Exemple #1
0
        public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data = new DTO.AVFPurchasingInvoice();
            data.Data.AVFPurchasingInvoiceDetails = new List <DTO.AVFPurchasingInvoiceDetail>();
            data.LedgerAccounts = new List <Module.Support.DTO.LedgerAccount>();
            data.Seasons        = new List <Module.Support.DTO.Season>();

            //try to get data
            try
            {
                if (id > 0)
                {
                    using (AVFPurchasingInvoiceMngEntities context = CreateContext())
                    {
                        var invoice = context.AVFPurchasingInvoiceMng_AVFPurchasingInvoice_View.FirstOrDefault(o => o.AVFPurchasingInvoiceID == id);
                        if (invoice == null)
                        {
                            throw new Exception("Can not found the invoice to edit");
                        }
                        data.Data = converter.DB2DTO_AVFPurchasingInvoice(invoice);
                    }
                }
                data.LedgerAccounts = supportFactory.GetLedgerAccount().ToList();
                data.Seasons        = supportFactory.GetSeason().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
        public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data = new DTO.LedgerAccount();
            data.Data.LedgerAccountDetailOverviews = new List <DTO.LedgerAccountDetailOverview>();
            data.LedgerAccounts = new List <Module.Support.DTO.LedgerAccount>();

            //try to get data
            try
            {
                if (id > 0)
                {
                    using (LedgerAccountMngEntities context = CreateContext())
                    {
                        var profile = context.LedgerAccountMng_LedgerAccount_View.FirstOrDefault(o => o.LedgerAccountID == id);
                        if (profile == null)
                        {
                            throw new Exception("Can not found the account to edit");
                        }
                        data.Data = converter.DB2DTO_LedgerAccount(profile);
                    }
                }
                data.LedgerAccounts = supportFactory.GetLedgerAccount().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }