Пример #1
0
        public ActionResult Paycheck(int paycheckID)
        {
            Paycheck paycheck = dbWorkMate.Paychecks.Find(paycheckID);

            if (paycheck == null)
            {
                return(HttpNotFound());
            }
            else if (paycheck.UserID != User.Identity.GetUserId())
            {
                return(new HttpUnauthorizedResult());
            }
            else
            {
                paycheck.PaycheckDetails = dbWorkMate.PaycheckDetails
                                           .Include(p => p.Paycheck)
                                           .Include(p => p.Paycheck.Job)
                                           .Include(p => p.Paycheck.PayDate)
                                           .Include(p => p.Schedule)
                                           .Where(e => e.PaycheckID == paycheck.ID)
                                           .ToList();

                PaycheckViewModel paycheckVM = new PaycheckViewModel()
                {
                    Paycheck = paycheck
                };

                return(View(paycheckVM));
            }
        }
Пример #2
0
        public IEnumerable <PaymentViewModel> Resolve(
            Paycheck source,
            PaycheckViewModel destination,
            IEnumerable <PaymentViewModel> destMember,
            ResolutionContext context)
        {
            var payments = !string.IsNullOrEmpty(source.Payments) ? (ListOfPayments)source.Payments : ListOfPayments.Create();

            return(context.Mapper.Map <IEnumerable <Payment>, IEnumerable <PaymentViewModel> >(payments));
        }
Пример #3
0
        public ActionResult Edit(PaycheckViewModel paycheckModel)
        {
            if (this.ModelState.IsValid)
            {
                var paycheck = this.mapService.Map <EmployeePaycheck>(paycheckModel);

                this.employeePaycheckService.UpdateById(paycheck.Id, paycheck);
                return(RedirectToAction("Index", "Paychecks"));
            }
            return(View(paycheckModel));
        }
Пример #4
0
        public ActionResult Edit(int id, PaycheckViewModel paycheckModel)
        {
            var paycheck = this.employeePaycheckService.GetById(id);

            if (paycheck == null)
            {
                return(HttpNotFound());
            }
            paycheckModel = this.mapService.Map <PaycheckViewModel>(paycheck);

            return(View("Edit", paycheckModel));
        }
        // GET: Paychecks
        public ActionResult Index()
        {
            var paychecks = dbBusiness.Paychecks.OrderByDescending(p => p.paycheck_date);
            List <PaycheckViewModel> paycheckModels = new List <PaycheckViewModel>();

            foreach (var i in paychecks)
            {
                var iModel = PaycheckViewModel.ToModel(i);
                paycheckModels.Add(iModel);
            }
            return(View(paycheckModels));
        }
        // GET: Paychecks/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PaycheckViewModel paycheck = PaycheckViewModel.ToModel(dbBusiness.Paychecks.Find(id));

            if (paycheck == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ActionTitle = "Detailed ";
            return(View(paycheck));
        }
Пример #7
0
        /// <summary>
        /// Builds summary money values of the paycheck
        /// </summary>
        /// <param name="people"></param>
        /// <param name="paycheckAmount"></param>
        /// <returns></returns>
        private PaycheckViewModel BuildPaycheckView(List <PaycheckPeopleViewModel> people, decimal paycheckAmount)
        {
            var paycheckView = new PaycheckViewModel();

            foreach (var p in people)
            {
                paycheckView.Deductions += p.Deduction;
                paycheckView.Discounts  += p.Discount;
            }

            paycheckView.PayPeriodSalary = _paycheck.Round(paycheckAmount);
            paycheckView.TotalDeductions = _paycheck.Round(paycheckView.Deductions - paycheckView.Discounts);
            paycheckView.PaycheckAmount  = _paycheck.Round(paycheckAmount - paycheckView.TotalDeductions);

            return(paycheckView);
        }
        public async Task <ActionResult <Employee> > GetPaycheck(int id)
        {
            var employee = await _employeeComponent.GetAsync(id);

            var paycheck = _employeeComponent.GetPayCheck(employee);

            var vm = new PaycheckViewModel
            {
                FullName    = $"{employee.FirstName} {employee.LastName}",
                BenefitCost = paycheck.BenefitCost,
                Salary      = paycheck.Salary,
                Total       = paycheck.Total
            };

            return(Ok(vm));
        }
Пример #9
0
        /// <summary>
        /// Iterates through the db result set and builds a paycheck view
        /// </summary>
        /// <param name="emp">List query result</param>
        /// <returns></returns>
        private PaycheckViewModel BuildPaycheck(List <PaycheckQuery> emp)
        {
            var people       = new List <PaycheckPeopleViewModel>();
            var paycheckView = new PaycheckViewModel();

            try
            {
                //if any exceptions occur, they will result from settings not being pulled from Deductions table correctly, or are missing
                var person = new PaycheckPerson {
                    FirstName = emp[0].FirstName, LastName = emp[0].LastName, Salary = emp[0].Salary, EmpType = Constants.EmployeeType
                };

                var employee = BuildPaycheckModel(person);
                people.Add(employee);

                if (emp.Count > 1)
                {
                    foreach (var d in emp)
                    {
                        person = new PaycheckPerson {
                            FirstName = d.DependentFirstName, LastName = d.LastName, Salary = 0, EmpType = Constants.DependentType
                        };
                        var dependent = BuildPaycheckModel(person);
                        people.Add(dependent);
                    }
                }
                paycheckView        = BuildPaycheckView(people, _paycheck.CalculatePayPeriodValue(emp[0].Salary, DeductionContstants.NumberOfPayPeriods));
                paycheckView.People = people;
            }
            catch (Exception)
            {
                //LOG to the database or other means
                throw;
            }
            return(paycheckView);
        }
Пример #10
0
        public ActionResult DeleteConfirmed(int id, PaycheckViewModel paycheckViewModel)
        {
            this.employeePaycheckService.DeleteById(id);

            return(RedirectToAction("Index", "Paychecks"));
        }