public async Task<IActionResult> AddWageSchemaForUser(AddWageSchemaForUserViewModel vm) { vm.Users = new SelectList(new List<SelectListItem>(), "Value", "Text"); if (ModelState.IsValid) { var adminServ = new AdminServices(uow); var currentAdmin = await GetCurrentUserAsync(); var result = adminServ.GetUsersForAdmin(currentAdmin.Email); if (!result.Success) { ModelState.AddModelError(string.Empty, result.Message); return View(vm); } var result2 = adminServ.AddWageSchemaForUser( currentAdmin.Email ,vm.SelectedUser, vm.Title, vm.HourlyWage); if (!result2.Success) { ModelState.AddModelError(string.Empty, result.Message); return View(vm); } vm.Users = CreateUserList(result.ReturnValue); vm.Message = result2.Message; return View(vm); } ModelState.AddModelError(string.Empty, "felaktig inmatning"); return View(vm); }
public async Task<IActionResult> AddWageSchemaForUser() { var vm = new AddWageSchemaForUserViewModel(); var adminServ = new AdminServices(uow); var currentAdmin = await GetCurrentUserAsync(); var result = adminServ.GetUsersForAdmin( currentAdmin.Email ); if ( !result.Success) { vm.Users = new SelectList(new List<SelectListItem>(), "Value", "Text"); return View(vm); } vm.Users = CreateUserList(result.ReturnValue); return View(vm); }