예제 #1
0
        public IActionResult Officers(int companyId)
        {
            ViewBag.CompanyId = companyId;

            AddOfficerVM addOfficerVM = new AddOfficerVM();

            addOfficerVM.CompanyId      = companyId;
            addOfficerVM.DepartmentList = _masterDataService.GetDepartments(companyId).Select(x => new SelectListItem()
            {
                Text = x.DepartmentName, Value = x.Id.ToString()
            });
            return(View(addOfficerVM));
        }
예제 #2
0
        public IActionResult CreateOfficer(AddOfficerVM addOfficerVM)
        {
            if (!ModelState.IsValid)
            {
                ShowToaster("Please fill required fields", ToasterLevel.Danger);
                return(RedirectToAction("Officers", "Company", new { companyId = addOfficerVM.CompanyId }));
            }
            var           config = new MapperConfiguration(cfg => cfg.CreateMap <AddOfficerVM, AddOfficerDTO>());
            var           mapper = new Mapper(config);
            AddOfficerDTO dto    = mapper.DefaultContext.Mapper.Map <AddOfficerDTO>(addOfficerVM);

            _userService.CreateAndUpdateOfficer(dto);
            ShowToaster("Officer created successfully", ToasterLevel.Success);

            return(RedirectToAction("Officers", "Company", new { companyId = dto.CompanyId }));
        }