Beispiel #1
0
        public async Task <IActionResult> Put(int id, [FromBody] PutTagDto dto)
        {
            var tag = await _tagService.PutAsync(id, dto);

            if (tag == null)
            {
                return(NotFound());
            }
            else
            {
                return(new JsonResult(tag));
            }
        }
Beispiel #2
0
        public async Task Put()
        {
            await DbContext.Tags.AddAsync(new Tag { Name = "Visual Studio" });

            await DbContext.SaveChangesAsync();

            var svc    = new TagService(DbContext, Mapper);
            var putDto = new PutTagDto
            {
                Name      = "VS",
                Color     = "Blue",
                GlyphFont = "Segoe MDL2 Assets"
            };

            await svc.PutAsync(1, putDto);

            var tags = await DbContext.Tags.ToListAsync();

            Assert.AreEqual(1, tags.Count);
            Assert.AreEqual("VS", tags[0].Name);
            Assert.AreEqual("Blue", tags[0].Color);
            Assert.IsNull(tags[0].Glyph);
            Assert.AreEqual("Segoe MDL2 Assets", tags[0].GlyphFont);
        }