Beispiel #1
0
        public static async Task <Guid> CreateAsync(DbContextOptions <MemCheckDbContext> testDB, string?name = null)
        {
            using var dbContext = new MemCheckDbContext(testDB);
            var result = new CardLanguage {
                Name = name ?? RandomHelper.String()
            };

            dbContext.CardLanguages.Add(result);
            await dbContext.SaveChangesAsync();

            return(result.Id);
        }
Beispiel #2
0
        protected override async Task <ResultWithMetrologyProperties <Result> > DoRunAsync(Request request)
        {
            var language = new CardLanguage()
            {
                Name = request.Name
            };

            DbContext.CardLanguages.Add(language);
            await DbContext.SaveChangesAsync();

            var result = new Result(language.Id, language.Name, 0);

            return(new ResultWithMetrologyProperties <Result>(result, ("Name", request.Name)));
        }
Beispiel #3
0
        public async Task <GetAllLanguages.ViewModel> RunAsync(Request request)
        {
            if (request.Name.Length < 4)
            {
                throw new InvalidOperationException($"Invalid language name '{request.Name}'");
            }
            var language = new CardLanguage()
            {
                Name = request.Name
            };

            dbContext.CardLanguages.Add(language);
            await dbContext.SaveChangesAsync();

            return(new GetAllLanguages.ViewModel(language.Id, language.Name, 0));
        }