public async Task <Response> Handle(CreateMerchantCommand request, CancellationToken cancellationToken) { var createMerchantRequest = _mapper.Map <MerchantDto>(request); createMerchantRequest.UniqueId = _guidGenerator.Generate(); var createMerchantResult = await _merchantRepository.CreateMerchant(createMerchantRequest); return(createMerchantResult.IsSuccess ? new Response(HttpStatusCode.OK) : new Response(HttpStatusCode.BadRequest)); }
public async Task <IActionResult> CreateMerchant() { var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } await _merchantRepository.CreateMerchant(user.Id); StatusMessage = "Merchant account successfully created."; return(RedirectToAction(nameof(Merchant))); }
public IActionResult CreateUser([FromBody] Merchant merchantToCreate) { if (merchantToCreate == null) { return(BadRequest(ModelState)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_merchantRepository.CreateMerchant(merchantToCreate)) { ModelState.AddModelError("", $"Something went wrong saving {merchantToCreate.Name}"); return(StatusCode(500, ModelState)); } return(CreatedAtRoute("GetMerchant", new { merchantId = merchantToCreate.Id }, merchantToCreate)); }