public async Task <IActionResult> CreateList( [FromBody, Bind("Listidentifier", "Keyword")] AuthorizationModel listAuth) { if (!listAuth.Validate()) { return(BadRequest(ErrorModel.BadRequest())); } listAuth.LowerIdentifier(); if (db.Lists.FirstOrDefault(l => l.Identifier == listAuth.ListIdentifier) != null) { return(BadRequest(ErrorModel.AlreadyExists())); } var list = new List(listAuth.ListIdentifier, listAuth.Keyword); var masterKey = SecureRandom.GenerateMasterKey(32); list.MasterKeyHash = Hashing.CreatePasswordHash(masterKey); await db.Lists.AddAsync(list); await db.SaveChangesAsync(); var outList = new ListCreated(list, masterKey); return(Created("list", outList)); }
private void DoneButton_Click(object sender, RoutedEventArgs routedEventArgs) { MainViewModel.AddList(new ArmyList(NameTextBox.Text, (Army)ArmyComboBox.SelectedItem, int.Parse(PointsTextBox.Text))); ListCreated?.Invoke(this, new EventArgs()); ArmyComboBox.SelectedIndex = -1; PointsTextBox.Text = string.Empty; NameTextBox.Text = string.Empty; }
public Output Process(Message msg, IMessageContext model) { switch (msg) { case CreateListCommand cmd: var existingListNames = new HashSet <string>((model as CreateListContext).ListNames); if (existingListNames.Contains(cmd.Name)) { return(new Output(new Failure($"List name '{cmd.Name}' already exists!"))); } var e = new ListCreated { Name = cmd.Name }; return(new Output(new Success(), new Event[] { e })); default: throw new NotImplementedException($"Message processing not implemented for '{msg}'!"); } }
public async void OnGetResultButtonClicked(object sender, MouseEventArgs e, bool isAsync) { var iterationsTimeList = new List <long>(); for (var i = 0; i < _amountOfIterations; ++i) { var timer = Stopwatch.StartNew(); if (isAsync) { await _data.WriteDataFromUrlAsync(); } else { var thread = new Thread(_data.WriteDataFromUrlSync); thread.Start(); thread.Join(); } timer.Stop(); iterationsTimeList.Add(timer.ElapsedMilliseconds); } ListCreated?.Invoke(iterationsTimeList, isAsync); }
public IEvent transformEvent(ListCreated toTransform, IEvent transformAgainst) { if (transformAgainst.GetType().Equals(typeof(ListCreated))) { if (toTransform.name == ((ListCreated)transformAgainst).name) { return new Unused(); } else { //Cannot simultaniously create lists. return null; } } return toTransform; }