Пример #1
0
        // GET: Employee/Edit/5
        public async Task <IActionResult> Self(string id)
        {
            var resopnse = await _EmployeeSelfReferenceService.Handle(new EmployeeSelfReferenceRequest(id));

            TempData["HumanType"] = HumanType;
            return(View(EmployeeViewModelFactory.ToSelfViewModle(resopnse)));
        }
Пример #2
0
        public IActionResult Create(string returnUrl)
        {
            if (String.IsNullOrEmpty(returnUrl))
            {
                returnUrl = Request.Headers["Referer"].ToString();
            }

            return(View("Edit", EmployeeViewModelFactory.Create(new EmployeeDto(), returnUrl, EmployeeDepartments)));
        }
Пример #3
0
        public async Task <IActionResult> Delete(int id)
        {
            var returnUrl = Request.Headers["Referer"].ToString();

            var employee = await _employeeRepo.GetEmployee(id);

            EmployeeViewModel employeeVm = EmployeeViewModelFactory.Delete(employee, returnUrl, EmployeeDepartments);

            return(View("Edit", employeeVm));
        }
Пример #4
0
        // GET: Employee/Edit/5
        public async Task <IActionResult> Family(string id)
        {
            EmployeeFamilyReferenceResponse resopnse = await _EmployeeFamilyReferenceService.Handle(
                new EmployeeFamilyReferenceRequest()
            {
                EmployeeId = id
            });

            TempData["HumanType"] = HumanType;

            return(View(EmployeeViewModelFactory.ToFamilyViewModel(resopnse)));
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, string returnUrl = null)
        {
            if (String.IsNullOrEmpty(returnUrl))
            {
                returnUrl = Request.Headers["Referer"].ToString();
            }

            var employee = await _employeeRepo.GetEmployee(id);

            EmployeeViewModel employeeVm = EmployeeViewModelFactory.Edit(employee, returnUrl, EmployeeDepartments);

            return(View("Edit", employeeVm));
        }
Пример #6
0
        public async Task <IActionResult> Edit([FromForm] EmployeeViewModel employeeVM)
        {
            if (ModelState.IsValid)
            {
                await _employeeRepo.UpdateEmployee(employeeVM.Employee);

                TempData["message"]     = "Your data has been updated successfully.";
                TempData["toasterType"] = ToasterType.success;

                return(RedirectToAction(nameof(Edit), new { id = employeeVM.Employee.Id, returnUrl = employeeVM.ReturnUrl }));
            }
            else
            {
                TempData["message"]     = "A problem has been ocurred while updating your data.";
                TempData["toasterType"] = ToasterType.info;
            }

            return(View("Edit", EmployeeViewModelFactory.Edit(employeeVM.Employee, employeeVM.ReturnUrl, EmployeeDepartments)));
        }
Пример #7
0
        public async Task <IActionResult> Create([FromForm] EmployeeViewModel employeeVm)
        {
            if (ModelState.IsValid)
            {
                employeeVm.EmployeeDepartment = default;


                var newEmployee = await _employeeRepo.AddEmployee(employeeVm.Employee);

                TempData["message"]     = "Your data has been submitted successfully.";
                TempData["toasterType"] = ToasterType.success;

                //return RedirectToAction(nameof(Index));

                return(RedirectToAction(nameof(Edit), new { id = newEmployee.Id, returnUrl = employeeVm.ReturnUrl }));
            }

            TempData["message"]     = "A problem has been ocurred while submitting your data.";
            TempData["toasterType"] = ToasterType.info;

            return(View("Edit", EmployeeViewModelFactory.Create(employeeVm.Employee, employeeVm.ReturnUrl, EmployeeDepartments)));
        }
Пример #8
0
        // GET: Employee/Details/5
        public async Task <IActionResult> Details(string id)
        {
            var responce = await _EmployeeDetailReferenceService.Handle(new EmployeeDetailReferenceRequest(id));

            return(View(EmployeeViewModelFactory.ToDetailViewModel(responce)));
        }
Пример #9
0
        // GET: Employee
        public async Task <IActionResult> Index()
        {
            EmployeeListResponse responce = await _EmployeeListService.HandleAsync(new EmployeeListRequest());

            return(View(EmployeeViewModelFactory.ToListViewModel(responce)));
        }