Пример #1
0
        public async Task <IActionResult> Register(
            [FromForm] UserRegisterParams form)
        {
            if (_userService.UsernameOrEmailTaken(form.UserName, form.Email))
            {
                return(BadRequest("Username or email already taken"));
            }

            try
            {
                await _registrationRepository.AddAsync(new RegistrationRequest
                {
                    Email    = form.Email,
                    Password = form.Password,
                    UserName = form.UserName
                });
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e);
                return(BadRequest("Invalid data provided"));
            }

            return(Ok("Account creation request sent"));
        }
Пример #2
0
        public async Task <Outcome <int> > Register(CustomerServiceModel customerServiceModel)
        {
            CustomerEntity customer = _mapper.Map <CustomerEntity>(customerServiceModel);

            bool IsCustomerExist = await _customerRepository.IsPolicyAlreadyRegistered(customer);

            if (IsCustomerExist)
            {
                return(new Outcome <int>(
                           "Policy has already registered, please check the policy reference number", System.Net.HttpStatusCode.BadRequest, 0));
            }

            var savedEntity = await _customerRepository.AddAsync(customer);

            if (savedEntity?.CustomerId != 0)
            {
                return(new Outcome <int>(
                           "Customer registered sucessfully", System.Net.HttpStatusCode.OK, savedEntity.CustomerId));
            }
            else
            {
                return(new Outcome <int>(
                           "Please try again, Request has not processed", System.Net.HttpStatusCode.ServiceUnavailable, 0));
            }
        }
Пример #3
0
        public async Task <int> AddAsync(RegistrationDTO entity)
        {
            if (entity.Status)
            {
                var seminar = await seminarRepository.GetAsync(entity.SeminarId);

                seminar.ParticipantsCount++;
                await seminarRepository.UpdateAsync(seminar);
            }
            return(await registrationRepository.AddAsync(entity));
        }
        public async Task <ActionResult> Create([Bind(Include = "PhoneNumber, Name")] Registration registration)
        {
            if (ModelState.IsValid)
            {
                registration.SecurityCode = random.Next(99999).ToString("D5");
                registration.Status       = "Unconfirmed";
                await _repository.AddAsync(registration);

                await _smsClient.SendMessageAsync("Thank you for registering to our service. Please reply with your security code to activate your registration", registration.PhoneNumber);

                return(RedirectToAction("Index"));
            }

            return(View(registration));
        }