示例#1
0
        public void UpdateGenre(Genre genre)
        {
            Genre item = context.Genres.FirstOrDefault(x => x.Id == genre.Id);

            if (item != null)
            {
                context.Entry(item).CurrentValues.SetValues(genre);
                context.SaveChanges();
            }
        }
示例#2
0
        public void UpdateTag(Tag tag)
        {
            Tag item = context.Tags.FirstOrDefault(x => x.Id == tag.Id);

            if (item != null)
            {
                context.Entry(item).CurrentValues.SetValues(tag);
                context.SaveChanges();
                Console.WriteLine("Successfully update tag!");
            }
        }
        public async Task <ActionResult> Put(int id, [FromBody] GenreCreateDTO model)
        {
            try
            {
                var entity = _automapper.Map <Genre>(model);
                entity.Id = id;
                _db.Entry(entity).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
 public void Update(Role item)
 {
     _applicationDbContext.Entry(item).State = EntityState.Modified;
 }