Exemple #1
0
        public async Task<IActionResult> AddProfession(AddProfessionViewModel  vm)
        {
            var compServ = new CompanyServices(uow);
            var appUser = await GetCurrentUserAsync();
            var compResult = compServ.GetCompaniesForUser(appUser.Email);
            vm.Companies = CreateCompanyList(compResult.ReturnValue);
            if ( ModelState.IsValid)
            {
                var currentUser = uow.UserRepository.GetEagerLoad(u => u.Email.Equals(appUser.Email, StringComparison.OrdinalIgnoreCase) ).FirstOrDefault();
                var adminServices = new AdminServices(uow);
                var result = adminServices.Addprofession(appUser.Email,  vm.SelectedValue,   currentUser.UserID , vm.Title, vm.Description); 
if( result.Success)
                {
                    vm.Message = result.Message;
                    return View(vm); 
                }
                else
                {
                    ModelState.AddModelError(string.Empty, result.Message);
                    return View(vm);
                }
            }
            ModelState.AddModelError(string.Empty, "incorrect input");
            return View(vm);
        }
Exemple #2
0
 public async Task<IActionResult> AddProfession()
 {
     var appUser = await GetCurrentUserAsync();
     var compServ = new CompanyServices(uow);
     var  result =compServ.GetCompaniesForUser(appUser.Email);            
     if( !result.Success )
     {
         ModelState.AddModelError(string.Empty, result.Message);
         return View(); 
     }
         AddProfessionViewModel vm = new AddProfessionViewModel();
     vm.Companies = CreateCompanyList(result.ReturnValue);
     
     return View(vm);
 }