示例#1
0
        public ActionResult <BusinessSetupStepsViewModel> SaveSteps([FromBody] BusinessSetupStepsViewModel model)
        {
            var business = _businessRepository.GetSingle(x => x.BusinessOwner.User.Auth0UserId == model.Auth0Id, x => x.BusinessOwner, x => x.BusinessOwner.User, x => x.BusinessCategory);

            _mapper.Map(model.Step1, business);
            _mapper.Map(model.Step2, business);

            _businessRepository.Commit();

            return(model);
        }
示例#2
0
        public ActionResult <AuthData> Post([FromBody] RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user     = _mapper.Map <User>(model);
            var business = _mapper.Map <Business>(model);

            var emailUnique = _userRepository.IsEmailUnique(model.Email);

            if (emailUnique)
            {
                business.BusinessOwner = new BusinessOwner()
                {
                    User = user
                };

                business.BusinessCategory = new BusinessCategory()
                {
                };

                _userRepository.Add(user);
                _userRepository.Commit();

                _businessRepository.Add(business);
                _businessRepository.Commit();
            }
            else
            {
                business = _businessRepository.GetSingle(x => x.BusinessOwner.User.Auth0UserId == model.Auth0UserId, x => x.BusinessOwner, x => x.BusinessOwner.User);
                user     = business.BusinessOwner.User;
            }

            return(new AuthData()
            {
                BusinessId = business.Id,
                UserId = user.Id
            });
        }