public async Task <IActionResult> Create(CreateCreditCardBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            await this.creditCardService.Create(model, this.User.Identity.Name);

            return(this.RedirectToAction(ActionConstants.Index, ControllerConstants.CreditCards));
        }
Example #2
0
        public async Task <string> Create(CreateCreditCardBindingModel model, string username)
        {
            Validator.ThrowIfNull(model);

            var client = await this.GetUserByNamedAsync(username);

            var creditCard = this.Mapper.Map <CreditCard>(model);

            creditCard.CustomerId     = client.Id;
            creditCard.DateRegistered = DateTime.Now;

            await this.Repository.AddAsync(creditCard);

            await this.Repository.SaveChangesAsync();

            return(creditCard.Id);
        }