public async Task <IActionResult> Edit(int?id, [Bind("InsuranceAgreementID,Price,BuyDate,State,DateFrom,DateTo,AdditionalInfo,InsuranceID,InsurancePackageID,ClientID,InvoiceID")] InsuranceAgreement insuranceAgreement)
        {
            if (id != insuranceAgreement.InsuranceID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(insuranceAgreement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InsuranceAgreementExists(insuranceAgreement.InsuranceID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientID"]           = new SelectList(_context.Clients, "PersonID", "PersonID", insuranceAgreement.ClientID);
            ViewData["InsuranceID"]        = new SelectList(_context.Insurances, "InsuranceID", "InsuranceID", insuranceAgreement.InsuranceID);
            ViewData["InsurancePackageID"] = new SelectList(_context.InsurancePackages, "InsurancePackageID", "InsurancePackageID", insuranceAgreement.InsurancePackageID);
            return(View(insuranceAgreement));
        }
        public async Task <IActionResult> Create([Bind("InsuranceAgreementID,Price,BuyDate,State,DateFrom,DateTo,AdditionalInfo,InsuranceID,InsurancePackageID,ClientID,InvoiceID")] InsuranceAgreement insuranceAgreement)
        {
            if (ModelState.IsValid)
            {
                _context.Add(insuranceAgreement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientID"]           = new SelectList(_context.Clients, "PersonID", "PersonID", insuranceAgreement.ClientID);
            ViewData["InsuranceID"]        = new SelectList(_context.Insurances, "InsuranceID", "InsuranceID", insuranceAgreement.InsuranceID);
            ViewData["InsurancePackageID"] = new SelectList(_context.InsurancePackages, "InsurancePackageID", "InsurancePackageID", insuranceAgreement.InsurancePackageID);
            return(View(insuranceAgreement));
        }