Ejemplo n.º 1
0
        public async Task SeedAsync()
        {
            var userId = Guid.NewGuid();
            await _userService.RegisterAsync(userId, "*****@*****.**", "default user", "secret");

            var tasks = new List <Task>();

            Guid English = await _categoryService.CreateAsync("English", userId);

            Guid Biology = await _categoryService.CreateAsync("Biology", userId);

            Guid Physics = await _categoryService.CreateAsync("Physics", userId);

            tasks.Add(_flashcardService.CreateAsync("pasjonujący", "thrilling", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("świadomy", "aware", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("poprzedzać", "to precede", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("omawiać", "to cover", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("szeroki", "wide", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("wąski", "narrow", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("zarządzać", "to manage", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("dudy", "bagpipes", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("cały i zdrowy", "safe and sound", English, Guid.NewGuid(), userId));
            tasks.Add(_flashcardService.CreateAsync("bardzo szybko, w oka mgnieniu", "in no time (at all)", English, Guid.NewGuid(), userId));

            await Task.WhenAll(tasks);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] CreateFlashcard command)
        {
            if (command == null)
            {
                throw new ArgumentException("Paramerets can not be null.");
            }
            command.FlashcardId = Guid.NewGuid();
            await _flashcardService.CreateAsync(command.Question, command.Answer, command.CategoryId, command.FlashcardId, UserId);

            //location header
            return(Created($"/api/flashcard/{command.FlashcardId}", null));
        }