Пример #1
0
        public ActionResult Create(OvertimeViewModel overtimeViewModel)
        {
            if (ModelState.IsValid)
            {
                var result = HRBusinessService.CreateOvertime(UserOrganisationId, overtimeViewModel.Overtime);
                if (result.Succeeded)
                {
                    return(RedirectToAction("profile", "personnel", new { id = overtimeViewModel.PersonnelId }));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error);
                }
            }
            var overtimePreferences = HRBusinessService.RetrieveOvertimePreferences(UserOrganisationId);
            var overtimeSummary     = HRBusinessService.RetrieveOvertimeSummary(UserOrganisationId, overtimeViewModel.PersonnelId);
            var personnel           = HRBusinessService.RetrievePersonnel(UserOrganisationId, overtimeViewModel.PersonnelId);

            overtimeViewModel.Overtime.Personnel = personnel;
            var viewModel = new OvertimeViewModel
            {
                Overtime            = overtimeViewModel.Overtime,
                OvertimePreferences = new SelectList(overtimePreferences, "OvertimePreferenceId", "Name"),
                OvertimeSummary     = overtimeSummary
            };

            return(View(viewModel));
        }