Example #1
0
        public InvoiceModel AddService(int invoiceId, int serviceTypeId, decimal rate)
        {
            var invoice = InvoiceRepository.GetInvoice(invoiceId);

            if (invoice == null)
            {
                throw new ArgumentException(string.Format("{0} is an invalid invoice number", invoiceId));
            }

            var serviceType = AvailableServiceTypes.Where(s => s.ServiceTypeId == serviceTypeId).FirstOrDefault();

            if (serviceType == null)
            {
                throw new ArgumentException(string.Format("{0} is an invalid service type id"));
            }

            var service = new Data.Graph.Service();

            service.ServiceDate = DateTime.Now;
            service.ServiceType = new Data.Graph.ServiceType(serviceType);
            service.Rate        = rate;
            invoice.AddService(service);

            InvoiceRepository.SaveInvoice(invoice);
            Logger.InfoFormat("Added service type id {0} to invoice {1}", serviceTypeId, invoiceId);

            return(Mapper.Map <Data.Graph.Invoice, Models.InvoiceModel>(invoice));
        }
Example #2
0
        public InvoiceModel AddService(int invoiceId, int serviceTypeId, decimal rate)
        {
            var invoice = InvoiceRepository.GetInvoice(invoiceId);
            if (invoice == null) throw new ArgumentException(string.Format("{0} is an invalid invoice number", invoiceId));

            var serviceType = AvailableServiceTypes.Where(s => s.ServiceTypeId == serviceTypeId).FirstOrDefault();
            if (serviceType == null) throw new ArgumentException(string.Format("{0} is an invalid service type id"));

            var service = new Data.Graph.Service();
            service.ServiceDate = DateTime.Now;
            service.ServiceType = new Data.Graph.ServiceType(serviceType);
            service.Rate = rate;
            invoice.AddService(service);

            InvoiceRepository.SaveInvoice(invoice);
            Logger.InfoFormat("Added service type id {0} to invoice {1}", serviceTypeId, invoiceId);

            return Mapper.Map<Data.Graph.Invoice, Models.InvoiceModel>(invoice);
        }