public async Task <IActionResult> CustomerCreateAccount(CustomerCreationModel ccm) { AppUser user = new AppUser { //TODO: Add the rest of the custom user fields here UserName = ccm.Email, Email = ccm.Email, FirstName = ccm.FirstName, LastName = ccm.LastName, Birthday = ccm.Birthday, PhoneNumber = ccm.PhoneNumber, ZIP = ccm.ZIP, State = ccm.State, Street = ccm.Street, City = ccm.City, AdvantageNumber = Utilities.GenerateAccountNumber.GetFFNum(_context), UserID = Convert.ToInt32(ccm.AdvantageNumber), Mileage = 0 }; IdentityResult result = await _userManager.CreateAsync(user, ccm.Password); if (result.Succeeded) { //TODO: Add user to desired role. This example adds the user to the customer role await _userManager.AddToRoleAsync(user, "Customer"); return(await AssignUser(ccm.TicketID, user.UserID)); } return(View("Error", new { message = "Customer Creation Failed" })); }
public Guid Create([FromBody] CustomerCreationModel customer) { var domainCustomer = new Customer(customer.UserId, customer.Name); this._aggregateStore.SaveAggregateAndEvents(domainCustomer); return(domainCustomer.Id); }
public Customer MapBackToEntity(CustomerCreationModel model) { return(new Customer { Name = model.Name, Address = model.Address }); }
public IActionResult CustomerCreateAccount(Int32 TicketID) { CustomerCreationModel ccm = new CustomerCreationModel(); ccm.TicketID = TicketID; return(View("Customer_CustomerCreation", ccm)); }
public static Customer ToCustomer(this CustomerCreationModel customerCreationModel) { return(new Customer { FirstName = customerCreationModel.FirstName, Surname = customerCreationModel.Surname, Address = customerCreationModel.Address, Email = customerCreationModel.Email }); }
public async Task <IActionResult> Post( [FromServices] ICommandHandler <CustomerCreationModel> createCustomerCommand, [FromBody] CustomerCreationModel customerCreationModel) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } await createCustomerCommand.Execute(customerCreationModel); return(this.Accepted()); }
public async Task <IActionResult> Post([FromBody] CustomerCreationModel customerCreationModel) { ValidationResult validationResult = _customerCreationModelValidator.Validate(customerCreationModel); if (!validationResult.IsValid) { DataResult <CustomerModel> dataResult = new DataResult <CustomerModel> { ResponseMessageType = ResponseMessageType.Error, }; return(BadRequest(dataResult)); } return(Ok(await _customerService.CreateCustomer(customerCreationModel))); }
public async Task <DataResult <CustomerModel> > CreateCustomer(CustomerCreationModel customerCreationModel) { Customer customer = _customerMapper.MapBackToEntity(customerCreationModel); customer.CreatedDate = DateTime.UtcNow; Customer addedCustomer = await _customerRepository.AddAsync(customer); await _customerRepository.SaveAsync(); CustomerModel customerModel = _customerMapper.MapToModel(addedCustomer); return(new DataResult <CustomerModel> { Data = customerModel, ResponseMessageType = ResponseMessageType.Success }); }