示例#1
0
        private void SetInvoiceContract()
        {
            InvoiceDetailView view = this._detailView as InvoiceDetailView;

            Katrin.Domain.Impl.Invoice invoice = this.ObjectEntity as Katrin.Domain.Impl.Invoice;
            if (view.SelectedContracts != null)
            {
                //Type contractType = DynamicTypeBuilder.Instance.GetDynamicType("InvoiceContract");
                var invoiceContracts = invoice.InvoiceContracts;

                while (invoiceContracts.Count > 0)
                {
                    invoiceContracts.RemoveAt(0);
                }
                foreach (var selectedContract in view.SelectedContracts)
                {
                    //var contract = Activator.CreateInstance(contractType);
                    var             scontract = ConvertData.Convert <InvoiceContract>(selectedContract);
                    InvoiceContract contract  = new InvoiceContract();
                    contract.InvoiceContractId = Guid.NewGuid();
                    contract.InvoiceId         = this.ObjectId;
                    contract.ContractId        = scontract.ContractId;
                    invoiceContracts.Add(contract);
                }
            }
        }
示例#2
0
 // GET: Invoices/Create
 public ActionResult Create(int? id)
 {
     var model = new InvoiceContract {InvoiceDate = DateTime.Now};
     if (id.GetValueOrDefault() > 0){
         var response =Singletone.Instance.DataStorageClient.
             CustomerOperation(new CustomerOperationRequest{
                 CustomerId = id,
                 Action = DataAction.Read
             });
         if (response.Customers.Any()){
             var customer = response.Customers.First();
             model.CustomerId = customer.Id.GetValueOrDefault();
             model.CustomerName = customer.FullName;
         }
     }
     return View(model);
 }
示例#3
0
        private int InvoiceConverter(int customerId)
        {
            var reference = 1;
            var expected = new InvoiceContract{
                Total = 0.0M,
                CustomerName = "Peter Pan",
                Description = "Test description",
                CustomerId = customerId,
                InvoiceDate = new DateTime(2015,11,12,11,29,51),
                InvoiceId = reference
            };

            var dao = new InvoiceDao();
            dao.ProcessRequest(new InvoiceOperationRequest{ Action = DataAction.Create, Invoice = expected });
            var result = dao.ProcessRequest(new InvoiceOperationRequest { Action = DataAction.Read, InvoiceId = 1 });

            var actual = result.Invoices.FirstOrDefault();
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Total, actual.Total);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.InvoiceDate, actual.InvoiceDate);
            Assert.AreEqual(expected.InvoiceId, actual.InvoiceId);
            return actual.InvoiceId;
        }