예제 #1
0
        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));
        }
예제 #2
0
 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;
 }
예제 #3
0
        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}'!");
            }
        }
예제 #4
0
        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;
 }