public async Task <IActionResult> PutTerminal([FromRoute] int id, [FromBody] TerminalVm terminalVm) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != terminalVm.Id) { return(BadRequest()); } _context.Entry(terminalVm).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TerminalExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <T> AddAsync(T entity) { _dbContext.Set <T>().Add(entity); await _dbContext.SaveChangesAsync(); return(entity); }
public async Task <RegistrationResult> Register(SellerRegisterDto sellerDto) { if (await IsEmailExistAsync(sellerDto.Email)) { return(RegistrationResult.EmailAlreadyExist); } var account = new Account { Email = sellerDto.Email, PasswordHash = _hashingService.CreateMD5(sellerDto.Password) }; await _context.Accounts.AddAsync(account); await _context.SaveChangesAsync(); var secretKey = new SecretKey { Value = "SellerSecretKey" + account.Id, AccountId = account.Id }; var seller = new Seller { AccountId = account.Id, PublicKey = "SellerPublicKey" + account.Id, }; await _context.SecretKeys.AddAsync(secretKey); await _context.Sellers.AddAsync(seller); await _context.SaveChangesAsync(); return(RegistrationResult.Success); }
public async Task <RegistrationResult> Register(PlatformRegisterDto platformDto) { if (await IsEmailExistAsync(platformDto.Email)) { return(RegistrationResult.EmailAlreadyExist); } var account = new Account { Email = platformDto.Email, PasswordHash = _hashingService.CreateMD5(platformDto.Password) }; await _context.Accounts.AddAsync(account); await _context.SaveChangesAsync(); var secretKey = new SecretKey { Value = "PlatformSecretKey" + account.Id, AccountId = account.Id }; var platform = new Platform { AccountId = account.Id, PublicKey = "PlatformPublicKey" + account.Id, }; await _context.SecretKeys.AddAsync(secretKey); await _context.Platforms.AddAsync(platform); await _context.SaveChangesAsync(); return(RegistrationResult.Success); }