public async Task <IActionResult> Edit(int id, [Bind("Id,ContractDetailId,PaymentDate,Reason,CreateDate")] PaymentDuration paymentDuration)
        {
            if (id != paymentDuration.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paymentDuration);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentDurationExists(paymentDuration.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractDetailId"] = new SelectList(_context.ContractDetail, "Id", "Id", paymentDuration.ContractDetailId);
            return(View(paymentDuration));
        }
        public ActionResult NewDuration([FromBody] PaymentDuration[] paymentDurations)
        {
            string result = "Sistem xətası";

            if (_context.PaymentDuration.Where(n => n.ContractDetailId == paymentDurations[0].ContractDetailId).ToList().Count != 0)
            {
                result = "Bu gecikmə üzrə qeyd mövcuddur";
                return(Json(result));
            }
            try
            {
                PaymentDuration paymentDuration = new PaymentDuration();
                paymentDuration.ContractDetailId = paymentDurations[0].ContractDetailId;
                paymentDuration.PaymentDate      = paymentDurations[0].PaymentDate;
                paymentDuration.Reason           = paymentDurations[0].Reason;
                paymentDuration.CreateDate       = DateTime.Now;

                _context.Add(paymentDuration);
                _context.SaveChanges();

                result = "Əməliyyat uğurla tamamlandı";
                return(Json(result));
            }
            catch (SqlException ex)
            {
                result = ex.Message;
                return(Json(result));
            }
        }
        public async Task <IActionResult> Create([Bind("Id,ContractDetailId,PaymentDate,Reason,CreateDate")] PaymentDuration paymentDuration)
        {
            if (ModelState.IsValid)
            {
                _context.Add(paymentDuration);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractDetailId"] = new SelectList(_context.ContractDetail, "Id", "Id", paymentDuration.ContractDetailId);
            return(View(paymentDuration));
        }
        public ActionResult EditDuration([FromBody] PaymentDuration[] paymentDurations)
        {
            string result = "Sistem xətası";

            try
            {
                PaymentDuration paymentDuration = new PaymentDuration();
                paymentDuration.Id          = paymentDurations[0].Id;
                paymentDuration.PaymentDate = paymentDurations[0].PaymentDate;
                paymentDuration.Reason      = paymentDurations[0].Reason;

                _context.Update(paymentDuration);
                _context.SaveChanges();

                result = "Əməliyyat uğurla tamamlandı";
                return(Json(result));
            }
            catch (Exception ex)
            {
                result = ex.Message;
                return(Json(result));
            }
        }