[HttpPost]//Add public async Task <ActionResult <Admin> > CreateAdminAsync(Admin Admin) { try { var returnAdmin = await _repository.AddAdmin(Admin); return(returnAdmin); } catch { return(NoContent()); } }
public async void AddAdminToDb() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: "yeet").Options; using (var context = new AppDbContext(options)) { Repository repo = new Repository(context); Admin Admin = new Admin(); Admin = await repo.AddAdmin(Admin); Assert.True(context.Admins.Contains(Admin)); } }
private void HandleCompleteCommand() { _canExecute = false; CompleteCommand.RaiseCanExecuteChanged(); if (_jdsuPort == null) { _jdsuPort = string.Empty; } if (_community == null) { _community = string.Empty; } var asyncAction = new Action(() => { var repository = new Repository(); repository.AddAdmin(_login, _firstPassword); repository.UpdateServicePort(Int32.Parse(_port)); repository.UpdateJdsu(_jdsuPort, _community); using (var serviceController = new ServiceController("WaterGate Service")) { if (serviceController.CanStop) { serviceController.Stop(); serviceController.WaitForStatus(ServiceControllerStatus.Stopped); } serviceController.Start(); } Environment.Exit(0); }); asyncAction.BeginInvoke(null, null); }