Example #1
0
        public IActionResult Index(SallaryReport sallaryReport)
        {
            var applicationContext = _context.SallaryReport
                                     .Include(sr => sr.Employee)
                                     .Include(sr => sr.ReportStatus);

            sallaryReport.TotalPayment = sallaryReport.TimeWorked
                                         * sallaryReport.PaymentPerHour;
            sallaryReport.DueToPay = sallaryReport.TimeWorked
                                     * sallaryReport.PaymentPerHour
                                     - sallaryReport.AmountPayed;
            return(View(sallaryReport));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ReportStatusId,Month,PersonId,TimeWorked,PaymentPerHour,TotalPayment,Payed,AmountPayed,DueToPay")] SallaryReport sallaryReport)
        {
            if (id != sallaryReport.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var applicationContext = _context.SallaryReport
                                             .Include(s => s.Employee)
                                             .Include(s => s.ReportStatus);
                    sallaryReport.TotalPayment = sallaryReport.TimeWorked
                                                 * sallaryReport.PaymentPerHour;
                    sallaryReport.DueToPay = sallaryReport.TimeWorked
                                             * sallaryReport.PaymentPerHour
                                             - sallaryReport.AmountPayed;

                    _context.Update(sallaryReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SallaryReportExists(sallaryReport.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(ListSallaryReports)));
            }
            ViewData["PersonId"]       = new SelectList(_context.Person, "Id", "CName", sallaryReport.PersonId);
            ViewData["ReportStatusId"] = new SelectList(_context.ReportStatus, "Id", "ReportStatusName", sallaryReport.ReportStatusId);
            return(View(sallaryReport));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("Id,ReportStatusId,Month,PersonId,TimeWorked,PaymentPerHour,TotalPayment,Payed,AmountPayed,DueToPay")] SallaryReport sallaryReport)
        {
            if (ModelState.IsValid)
            {
                var applicationContext = _context.SallaryReport
                                         .Include(s => s.Employee)
                                         .Include(s => s.ReportStatus);
                sallaryReport.TotalPayment = sallaryReport.TimeWorked
                                             * sallaryReport.PaymentPerHour;
                sallaryReport.DueToPay = sallaryReport.TimeWorked
                                         * sallaryReport.PaymentPerHour
                                         - sallaryReport.AmountPayed;


                _context.Add(sallaryReport);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ListSallaryReports)));
            }
            ViewData["PersonId"]       = new SelectList(_context.Person, "Id", "CName", sallaryReport.PersonId);
            ViewData["ReportStatusId"] = new SelectList(_context.ReportStatus, "Id", "ReportStatusName", sallaryReport.ReportStatusId);
            return(View(sallaryReport));
        }