public async Task <IActionResult> EditWorkerPenalty(WorkerPenalty model, int id)
        {
            WorkerPenalty penalty = await _payrollDb.WorkerPenalties.FindAsync(id);


            if (ModelState.IsValid)
            {
                if (penalty != null)
                {
                    penalty.Amount            = model.Amount;
                    penalty.PenaltyWritedDate = model.PenaltyWritedDate;
                    penalty.WorkerId          = model.WorkerId;


                    await _payrollDb.SaveChangesAsync();

                    return(RedirectToAction(nameof(ListWorkerPenalty)));
                }



                else
                {
                    return(Redirect("~/Account/Error"));
                }
            }
            else
            {
                return(View());
            }
        }
        public async Task <IActionResult> CreateWorkerPenalty(WorkerPenalty penalty)
        {
            if (ModelState.IsValid)
            {
                WorkerPenalty p = penalty;

                await _payrollDb.WorkerPenalties.AddAsync(p);

                await _payrollDb.SaveChangesAsync();

                return(RedirectToAction(nameof(ListWorkerPenalty)));
            }

            return(View(penalty));
        }