private bool FilterInsurancePolicies(InsurancePolicy entity)
 {
     return (entity.AutoId == this.AutoId);
 }
        public void Save(InsurancePolicy insurancePolicy, Action<SubmitOperation> submitCallback, object state)
        {
            if (insurancePolicy == null)
            {
                return;
            }

            if (insurancePolicy.InsurancePolicyId == 0)
            {
                Context.InsurancePolicies.Add(insurancePolicy);
            }

            if (Context.HasChanges)
            {
                Context.SubmitChanges(submitCallback, state);
            }
        }
 private void AttachInsurancePolicies(InsurancePolicy entity)
 {
     entity.Auto = this;
 }
 private void DetachInsurancePolicies(InsurancePolicy entity)
 {
     entity.Auto = null;
 }
 private bool FilterInsurancePolicies(InsurancePolicy entity)
 {
     return (entity.CompanyId == this.CompanyId);
 }
 private bool FilterInsurancePolicies(InsurancePolicy entity)
 {
     return (entity.AgencyName == this.AgencyId);
 }
 private void DetachInsurancePolicies(InsurancePolicy entity)
 {
     entity.Company = null;
 }
 private void AttachInsurancePolicies(InsurancePolicy entity)
 {
     entity.Company = this;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the InsurancePolicies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToInsurancePolicies(InsurancePolicy insurancePolicy)
 {
     base.AddObject("InsurancePolicies", insurancePolicy);
 }
 /// <summary>
 /// Create a new InsurancePolicy object.
 /// </summary>
 /// <param name="insurancePolicyId">Initial value of the InsurancePolicyId property.</param>
 public static InsurancePolicy CreateInsurancePolicy(global::System.Int32 insurancePolicyId)
 {
     InsurancePolicy insurancePolicy = new InsurancePolicy();
     insurancePolicy.InsurancePolicyId = insurancePolicyId;
     return insurancePolicy;
 }
        /// <summary>
        /// Executes when LaunchEditInsurancePolicyCommand is called
        /// </summary>
        public void LaunchEditInsurancePolicyExecute()
        {
            if (SelectedCalculatedInsurance == null)
            {
                return;
            }

            int companyId = SelectedCalculatedInsurance.CompanyId;
            decimal price = (decimal)SelectedCalculatedInsurance.Price;

            InsurancePolicy newInsurancePolicy =
                new InsurancePolicy()
                {
                    Auto =
                        new Auto()
                        {
                            AutoTypeId = AutoType == null? 0 : this.AutoType.AutoTypeId,
                            SeatsCount = this.SeatsCount,
                            MakeYear = this.FirstRegistrationYear,
                            PurposeId = Purpose == null ? 0: this.Purpose.PurposeId,
                            LoadingCapacity = this.LoadingCapacity,
                            Person = new Person()
                        },
                    CompanyId = companyId,
                    IssueDate = DateTime.Now,
                    EndDate = DateTime.Now.AddYears(1),
                    DriverExperienceYears = this.DriverExperience,
                    AgencyName = "ТУ-СОФИЯ Иншуърънс ООД",
                    Price = price

                };

            var newMessage =
                new LaunchEditInsuarancePolicyMessage()
                {
                    InsuarancePolicy = newInsurancePolicy
                };
            Messenger.Default.Send <LaunchEditInsuarancePolicyMessage>(newMessage);
        }