public async Task <IActionResult> Create(CreateApiKeyViewModel model) { if (ModelState.IsValid) { var merchantId = await _userService.GetCurrentMerchantId(User); var virtualTerminal = new Terminal { SerialNumber = Guid.NewGuid().ToString(), ApiSecret = GenerateApiSecret(), Name = model.Name, Status = model.Status, MerchantId = merchantId, StoreId = model.StoreId, ServiceProviderId = model.ServiceProviderId, Virtual = true }; _db.Add(virtualTerminal); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public async Task <IActionResult> Create() { var merchantId = await _userService.GetCurrentMerchantId(User); var model = new CreateApiKeyViewModel() { }; ViewData["ServiceProviderId"] = new SelectList(_db.ServiceProvider, "Id", "Name", null); ViewData["storeId"] = new SelectList(_db.Store.Where(t => t.MerchantId == merchantId), "Id", "Name", model.StoreId); return(View(model)); }