public async Task <IActionResult> SetUserType(UserType userType)
        {
            IActionResult result = null;
            var           user   = await userRepository.GetByName(User.Identity.Name);

            switch (userType.ChosenUserType)
            {
            case UserTypes.Company:
                await authenticationProvider.AddClaim(user, "CompanyRole", "Company");

                companiesRepository.Create(new Company {
                    UserId = user.Id
                });
                result = RedirectToAction("Index", "Dashboard", new { area = "Company" });     // TODO: Redirect to company Dashboard
                break;

            case UserTypes.Candidate:
                await authenticationProvider.AddClaim(user, "CandidateRole", "Candidate");

                candidateRepository.Create(new Candidate {
                    UserId = user.Id
                });
                result = RedirectToAction("Index", "Dashboard", new { area = "Candidate" });
                break;

            default:
                throw new ArgumentException("No user type with this name!");
            }

            await authenticationProvider.SignIn(user);

            return(result);
        }
Beispiel #2
0
        public async Task <Response <CompanyDTO> > Create(Guid userId, CompanyCreateDTO dto)
        {
            var entityCompany = new CompanyModel
            {
                Name        = dto.Name,
                Address     = dto.Address,
                CreatedDate = DateTime.UtcNow,
                CreatorId   = userId
            };

            entityCompany = await _repository.Create(entityCompany);

            await _companiesUsersRepository.AddCompanyUser(entityCompany.Id, userId, MembershipStatus.SuperAdmin);

            var result = _mapper.Map <CompanyModel, CompanyDTO>(entityCompany);

            return(new Response <CompanyDTO>
            {
                Data = result
            });
        }
 public CompanyModel Create(CompanyModel model)
 {
     return(_repository.Create(model));
 }