private void AddEmployee_OnClick(object sender, RoutedEventArgs e)
 {
     if (user.CurrentUser.Id != 1)
     {
         MessageBox.Show("Nie jesteś właścicielem, nie masz uprawnień do przeglądania tej zawartości.");
         return;
     }
     DataContext = new AddEmployeeVM(model);
 }
        public ActionResult AddEmployee()
        {
            if (Session["CurrentSession"] == null)
            {
                return(RedirectToAction("Login"));
            }
            AddEmployeeVM addEmployeeVM = new AddEmployeeVM();

            return(View(addEmployeeVM));
        }
 public ActionResult AddEmployee(AddEmployeeVM vm)
 {
     if (ModelState.IsValid)
     {
         Employee emp = new Employee {
             ID = vm.ID, Name = vm.Name, Designation = vm.Designation, Salary = vm.Salary
         };
         employeeService.AddEmployee(emp);
         return(RedirectToAction("Index"));
     }
     return(View(vm));
 }
Beispiel #4
0
        public IActionResult Employees(int companyId)
        {
            ViewBag.CompanyId = companyId;

            AddEmployeeVM addEmployeeVM = new AddEmployeeVM();

            addEmployeeVM.CompanyId      = companyId;
            addEmployeeVM.DepartmentList = _masterDataService.GetDepartments(companyId).Select(x => new SelectListItem()
            {
                Text = x.DepartmentName, Value = x.Id.ToString()
            });
            return(View(addEmployeeVM));
        }
Beispiel #5
0
        public IActionResult CreateEmployee(AddEmployeeVM addEmployeeVM)
        {
            if (!ModelState.IsValid)
            {
                ShowToaster("Please fill required fields", ToasterLevel.Danger);
                return(RedirectToAction("Employees", "Company", new { companyId = addEmployeeVM.CompanyId }));
            }
            var            config = new MapperConfiguration(cfg => cfg.CreateMap <AddEmployeeVM, AddEmployeeDTO>());
            var            mapper = new Mapper(config);
            AddEmployeeDTO dto    = mapper.DefaultContext.Mapper.Map <AddEmployeeDTO>(addEmployeeVM);

            _userService.CreateAndUpdateEmployee(dto);
            ShowToaster("Employee created successfully", ToasterLevel.Success);

            return(RedirectToAction("Employees", "Company", new { companyId = dto.CompanyId }));
        }
Beispiel #6
0
        public ActionResult AddEmployee()
        {
            AddEmployeeVM addEmployeeVM = new AddEmployeeVM();

            return(View(addEmployeeVM));
        }