public NewContractRequestLogic(Agent agent, Boolean incoming, NewContractRequest ncr)
        {
            callLog = new CallLog(DateTime.Now, incoming);
            callLog.Representative = agent;

            this.newContractRequest = ncr;
        }
コード例 #2
0
        public async Task Handler_Creates_New_Contract()
        {
            using (var context = new AppDbContext(_options))
            {
                context.Contracts.Count().Should().Be(0);
            }

            var request = new NewContractRequest()
            {
                User = new AppUser {
                    Id = 1
                },
                Name         = "New Contract",
                Employer     = "Test Employer",
                HoursPerWeek = 35,
                IsCurrent    = true
            };

            var response = await _testObject.Handle(request, CancellationToken.None);

            response.Should().BeTrue();

            using (var context = new AppDbContext(_options))
            {
                context.Contracts.Count().Should().Be(1);
                var contract = context.Contracts.FirstOrDefault(x => x.Name == "New Contract");
                contract.Employer.Should().Be("Test Employer");
                contract.HoursPerWeek.Should().Be(35);
                contract.IsCurrent.Should().BeTrue();
                contract.UserId.Should().Be(1);
            }
        }
コード例 #3
0
 public int Create(NewContractRequest o)
 {
     using (var db = new BillingDbContext())
     {
         db.ServiceRequests.Add(o);
         return(db.SaveChanges());
     }
 }
コード例 #4
0
        private async Task HandleValidSubmitAsync()
        {
            bool result = await Mediator.Send(Model);
            if (result)
            {
                Navi.NavigateTo("contracts");
            }

            Model = new NewContractRequest();
        }
コード例 #5
0
        public static void FullfillNewContractRequest(NewContractRequest newContractRequest)
        {
            Agent agent = frmSelectAgent.GetAgent();

            if (agent != null)
            {
                NewContractRequestLogic newContractRequestLogic = new NewContractRequestLogic(
                    agent,
                    false,
                    newContractRequest
                    );

                frmAddServiceContractToClient form = new frmAddServiceContractToClient(newContractRequestLogic);
                form.ShowDialog();
            }
        }
コード例 #6
0
        /******************************************************************************************
        * From domain model to value object
        ******************************************************************************************/
        public NewContractRequestDTO ToRequestDTO(NewContractRequest o)
        {
            var vo = new NewContractRequestDTO();

            ClassCopier.Instance.Copy(o, vo);

            if (o.RequestInfo != null)
            {
                vo.RequestInfo = ToRequestInfoDTO(o.RequestInfo);
            }
            if (o.Routings.Count > 0)
            {
                vo.Routings = ToRoutingInfosDTO(o.Routings);
            }
            return(vo);
        }
コード例 #7
0
        /******************************************************************************************
        * From value object to domain model
        ******************************************************************************************/
        public NewContractRequest ToRequest(NewContractRequestDTO vo)
        {
            var o = new NewContractRequest();

            ClassCopier.Instance.Copy(vo, o);

            if (vo.RequestInfo != null)
            {
                o.RequestInfo = ToRequestInfo(vo.RequestInfo);
            }
            if (vo.Routings.Count > 0)
            {
                o.Routings = ToRoutingInfos(vo.Routings);
            }
            return(o);
        }
        public void CreateNewNewContractRequest(ServiceContract serviceContract, Client client)
        {
            endCall();
            NewContractRequestController newContractRequestController = new NewContractRequestController();
            RequestController            requestController            = new RequestController();

            NewContractRequest newContractRequest = new NewContractRequest(
                DateTime.Now,
                null,
                callLog
                );

            newContractRequestController.Create(newContractRequest);
            newContractRequestController.Set(serviceContract, newContractRequest);
            requestController.Set(client, newContractRequest);
        }
コード例 #9
0
 public int Update(NewContractRequest o)
 {
     using (var db = new BillingDbContext())
     {
         var ori = Select(o.No, true);
         if (o.RequestInfo != null)
         {
             var ri = o.RequestInfo;
             if (ri.No == 0)
             {
                 ori.RequestInfo    = ri;
                 db.Entry(ri).State = EntityState.Added;
             }
             else
             {
                 db.RequestInfos.Attach(ori.RequestInfo);
                 db.Entry(ori.RequestInfo).CurrentValues.SetValues(ri);
                 db.Entry(ori.RequestInfo).State = EntityState.Modified;
             }
         }
         if (o.Routings.Count > 0)
         {
             var list1 = o.Routings;
             foreach (var ri1 in list1)
             {
                 if (ri1.No == 0)
                 {
                     ori.Routings.Add(ri1);
                     db.Entry(ri1).State = EntityState.Added;
                 }
                 else
                 {
                     var oriri = ori.Routings.Find(x => x.No == ri1.No);
                     if (oriri != null)
                     {
                         db.RoutingInfos.Attach(oriri);
                         ClassCopier.Instance.Copy(ri1, oriri);
                         db.Entry(oriri).State = EntityState.Modified;
                         if (ri1.Routings.Count > 0)
                         {
                             var list2 = ri1.Routings;
                             foreach (var ri2 in list2)
                             {
                                 if (ri2.No == 0)
                                 {
                                     oriri.Routings.Add(ri2);
                                     db.Entry(ri2).State = EntityState.Added;
                                 }
                                 else
                                 {
                                     var oriri2 = oriri.Routings.Find(y => y.No == ri2.No);
                                     db.RoutingItems.Attach(oriri2);
                                     db.Entry(oriri2).CurrentValues.SetValues(ri2);
                                     db.Entry(oriri2).State = EntityState.Modified;
                                 }
                             }
                         }
                         if (ri1.GetType() == typeof(NewContractExtLineRoutingInfo))
                         {
                             var oriri1 = oriri as NewContractExtLineRoutingInfo;
                             var ri2    = ri1 as NewContractExtLineRoutingInfo;
                             if (ri2 != null && ri2.Contract != null)
                             {
                                 if (oriri1 != null)
                                 {
                                     var ct = ri2.Contract;
                                     if (ct.No == 0)
                                     {
                                         oriri1.Contract    = ct;
                                         db.Entry(ct).State = EntityState.Added;
                                     }
                                     else
                                     {
                                         db.Entry(oriri1.Contract).CurrentValues.SetValues(ct);
                                         db.Entry(oriri1.Contract).State = EntityState.Modified;
                                     }
                                 }
                             }
                         }
                         else if (ri1.GetType() == typeof(NewContractIpPhoneRoutingInfo))
                         {
                             var oriri2 = oriri as NewContractIpPhoneRoutingInfo;
                             var ri3    = ri1 as NewContractIpPhoneRoutingInfo;
                             if (ri3 != null && ri3.Contract != null)
                             {
                                 if (oriri2 != null)
                                 {
                                     var ct = ri3.Contract;
                                     if (ct.No == 0)
                                     {
                                         oriri2.Contract    = ct;
                                         db.Entry(ct).State = EntityState.Added;
                                     }
                                     else
                                     {
                                         db.Entry(oriri2.Contract).CurrentValues.SetValues(ct);
                                         db.Entry(oriri2.Contract).State = EntityState.Modified;
                                     }
                                 }
                             }
                         }
                         else if (ri1.GetType() == typeof(NewContractLaptopRoutingInfo))
                         {
                             var oriri3 = oriri as NewContractLaptopRoutingInfo;
                             var ri4    = ri1 as NewContractLaptopRoutingInfo;
                             if (ri4 != null && ri4.Contract != null)
                             {
                                 if (oriri3 != null)
                                 {
                                     var ct = ri4.Contract;
                                     if (ct.No == 0)
                                     {
                                         oriri3.Contract    = ct;
                                         db.Entry(ct).State = EntityState.Added;
                                     }
                                     else
                                     {
                                         db.Entry(oriri3.Contract).CurrentValues.SetValues(ct);
                                         db.Entry(oriri3.Contract).State = EntityState.Modified;
                                     }
                                 }
                             }
                         }
                         else if (ri1.GetType() == typeof(NewContractSoftwareRoutingInfo))
                         {
                             var oriri4 = oriri as NewContractSoftwareRoutingInfo;
                             var ri5    = ri1 as NewContractSoftwareRoutingInfo;
                             if (ri5 != null && ri5.Contract != null)
                             {
                                 if (oriri4 != null)
                                 {
                                     var ct = ri5.Contract;
                                     if (ct.No == 0)
                                     {
                                         oriri4.Contract    = ct;
                                         db.Entry(ct).State = EntityState.Added;
                                     }
                                     else
                                     {
                                         db.Entry(oriri4.Contract).CurrentValues.SetValues(ct);
                                         db.Entry(oriri4.Contract).State = EntityState.Modified;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         db.Entry(o).State = EntityState.Modified;
         return(db.SaveChanges());
     }
 }
コード例 #10
0
        private NewContractRequest CreateNewContractRequestFullyPopulated()
        {
            NewContractRequest request = new NewContractRequest();

            request.Contact.Name = "Robert Gray";
            request.Contact.PostalAddress = new Address { Street = "22 Turrbal St",
                                                        Suburb = "Bellbowrie",
                                                        State = "QLD",
                                                        Postcode = "4070"};
            request.Contact.HomeAddress = new Address
            {
                Street = "22 Turrbal St",
                Suburb = "Bellbowrie",
                State = "QLD",
                Postcode = "4070"
            };
            request.Contact.MobilePhone = "0411331273";
            request.Contact.CreditCard = new CreditCard
                                             {
                                                 CardNumber = "12345865482343",
                                                 NameOnCard = "Mr Robert A Gray",
                                                 ExpiryDate = "03/10",
                                                 CreditCardType = CreditCardType.Visa
                                             };
            request.Contact.DriversLicense = new DriversLicense
                                                 {
                                                     LicenseNumber = "123482342",
                                                     DateOfBirth = DateTime.Parse("1976-08-21"),
                                                     Expiry = DateTime.Parse("2010-06-01")
                                                 };
            request.BillingMethod = BillingMethod.Invoice;
            request.BillingAddressType = BillingAddressType.Postal;
            request.ActivationDate = DateTime.Parse("2008-12-01");
            request.EndDate = DateTime.Parse("2010-12-01");
            request.Data = false;
            request.MessageBank = false;
            request.IMEINumber = "123232323";
            request.SimCard = "123232323";
            request.UsedBy = "Rob";
            request.IsBusinessContract = false;
            request.PlanId = 1;
            request.User = new User { Username = "******" };

            return request;
        }