Beispiel #1
0
        public async Task<ReturnModel<InvoiceModel>> GetByID (int invoiceID)
        {
            InvoiceModel invoiceModel = new InvoiceModel();
            using(var session = new UnitOfWork<FoodMenuEntities>())
            {
                var InvoiceRepository = session.GetRepository<IInvoiceRepository>();

                var invoice = await InvoiceRepository.GetByID(invoiceID);

                invoiceModel.Id = invoice.Id;
                invoiceModel.ClientId = invoice.ClientId;
                invoiceModel.Notes = invoice.Notes;
                invoiceModel.MeetingId = invoice.MeetingId;
                invoiceModel.Number = invoice.Number;

                return new ReturnModel<InvoiceModel>
                {
                    Status = true,
                    Result = invoiceModel
                };
            };
        }
Beispiel #2
0
        public async Task<ReturnModel<InvoiceModel>> Create (InvoiceModel invoiceModel)
        {
            var result = new ReturnModel<InvoiceModel> { Status = true };
            using(var session = new UnitOfWork<FoodMenuEntities>())
            {
                var InvoiceRepository = session.GetRepository<IInvoiceRepository>();

                var invoice = new Invoice();
                invoice.Id = invoiceModel.Id;
                invoice.ClientId = invoiceModel.ClientId;
                invoice.Notes = invoiceModel.Notes;
                invoice.MeetingId = invoiceModel.MeetingId;
                invoice.Number = invoiceModel.Number;
                InvoiceRepository.Add(invoice);

                await session.SaveChangesAsync();

                invoiceModel.Id = invoice.Id;
                result.Result = invoiceModel;
                return result;
            }
        }
Beispiel #3
0
 public async Task<ReturnModel<bool>> Put (int id,InvoiceModel Invoice)
 {
     Invoice.Id = id;
     return await InvoiceBl.Update(Invoice);
 }
Beispiel #4
0
 //[AllowAnonymous]
 public async Task<ReturnModel<InvoiceModel>> Post (InvoiceModel Invoice)
 {
     Invoice.Id = LogedInUser.Id;
     return await InvoiceBl.Create(Invoice);
 }
Beispiel #5
0
        public async Task<ReturnModel<bool>> Update (InvoiceModel invoiceModel)
        {
            using(var session = new UnitOfWork<FoodMenuEntities>())
            {
                var InvoiceRepository = session.GetRepository<IInvoiceRepository>();

                var invoice = await InvoiceRepository.GetByID(invoiceModel.Id);

                invoice.Id = invoiceModel.Id;
                invoice.ClientId = invoiceModel.ClientId;
                invoice.Notes = invoiceModel.Notes;
                invoice.MeetingId = invoiceModel.MeetingId;
                invoice.Number = invoiceModel.Number;
                await session.SaveChangesAsync();

                return new ReturnModel<bool> { Status = true };
            }
        }