public ActionResult Create(EmployeeWageRateVM model)
        {
            try
            {
                // TODO: Adding insert logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var empWageRate = _mapper.Map <EmployeeWageRate>(model);
                empWageRate.DateCreated = DateTime.Now;

                var isSuccess = _repo.Create(empWageRate);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "There is a fault somewhere...");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "There is a fault somewhere...");
                return(View(model));
            }
        }
Beispiel #2
0
        // Creating a custom action
        public ActionResult SetWage(int id)
        {
            var empjobinfo = _empjobinforepo.FindById(id);
            var employees  = _userManager.GetUsersInRoleAsync("Employee").Result;

            foreach (var emp in employees)
            {
                if (_empwagesrepo.CheckAllocation(id, emp.Id))
                {
                    continue;
                }

                var allocation = new EmployeeWageRateVM
                {
                    DateCreated       = DateTime.Now,
                    EmployeeId        = emp.Id,
                    EmployeeTypeId    = id,
                    MonthlyIncome     = int.MaxValue,
                    DailyRate         = int.MaxValue,
                    HourlyRate        = int.MaxValue,
                    Overtime          = string.Empty,
                    PercentSalaryHike = int.MaxValue,
                    Period            = DateTime.Now.Year,
                };
                var empwages = _mapper.Map <EmployeeWageRate>(allocation);
                _empwagesrepo.Create(empwages);
            }
            return(RedirectToAction(nameof(Index)));
        }