Example #1
0
        private Response <SignUpStepDTO> ValidateStep(UserRegistrationStepModel model, RegistrationStep step)
        {
            if (model.Step >= step)
            {
                return(new BusinessConflictErrorResponse <SignUpStepDTO>(new []
                {
                    new Error
                    {
                        Code = ErrorCodes.Business.InvalidRegistrationStep,
                        Message = ErrorMessages.Business.InvalidRegistrationStep
                    }
                })
                {
                    Data = new SignUpStepDTO
                    {
                        RegistrationStep = _mapper.Map <UserRegistrationStepModel, UserRegistrationStepDTO>(model)
                    }
                });
            }

            return(new Response <SignUpStepDTO>());
        }
Example #2
0
        public async Task <UserRegistrationStepModel> SetRegistrationStep(Guid userId, RegistrationStep step, MembershipStatus?status = null)
        {
            var item = await _context.UsersRegistrationStep
                       .Where(x => x.UserId == userId)
                       .FirstOrDefaultAsync();

            var stepExisted = true;

            if (item == null)
            {
                item = new UserRegistrationStepModel {
                    UserId = userId, CreatedDate = DateTime.Now
                };
                stepExisted = false;
            }

            item.Step        = step;
            item.UpdatedDate = DateTime.UtcNow;

            if (status.HasValue)
            {
                item.Status = status.Value;
            }

            if (stepExisted)
            {
                _context.Update(item);
            }
            else
            {
                _context.UsersRegistrationStep.Add(item);
            }
            await _context.SaveChangesAsync();

            return(item);
        }