Exemplo n.º 1
0
                public async Task<IActionResult> AddDepartment(AddDepartmentViewModel vm)
                {
                    var currentUser = await GetCurrentUserAsync();
                    vm.Companies = from c in uow.CompanyRepository.GetEagerLoad(w => w.CustomerAdminMail.Equals(currentUser.Email))
                                   select new SelectListItem
                                   {
                                       Text = c.CompanyName,
                                       Value = c.CompanyID
                                   };

                    if (ModelState.IsValid)
                    {
                        var depService = new DepartmentServices(uow);
                        var result = depService.SaveDepartment(vm.SelectedValue, vm.Title, vm.Description);
                        if (result.Success) { vm.Message = result.Message; }
                        else { ModelState.AddModelError(string.Empty, result.Message); }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "input incorrect");
                    }
                    return View(vm);
                }
Exemplo n.º 2
0
 public async Task<IActionResult> AddDepartment()
 {
     var currentUser = await GetCurrentUserAsync();
     var vm = new AddDepartmentViewModel();
     vm.Companies = from c in uow.CompanyRepository.GetEagerLoad(w => w.CustomerAdminMail.Equals(currentUser.Email))
                    select new SelectListItem
                    {
                        Text = c.CompanyName,
                        Value = c.CompanyID
                    };
     return View(vm);
 }