示例#1
0
 public bool UpdateGenre(GenreEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Genres
             .Single(e => e.GenreId == model.GenreId);
         entity.GenreId   = model.GenreId;
         entity.GenreName = model.GenreName;
         return(ctx.SaveChanges() == 1);
     }
 }
示例#2
0
        public IHttpActionResult Put(GenreEdit genre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateGenreService();

            if (!service.UpdateGenre(genre))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
示例#3
0
 public bool UpdateGenre(GenreEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         try
         {
             var entity = ctx.Genres.Single(e => e.Id == model.Id);
             entity.Name        = model.Name;
             entity.Description = model.Description;
             entity.ModifiedUtc = DateTimeOffset.Now;
             return(ctx.SaveChanges() == 1);
         }
         catch (Exception e)
         {
             Debug.Print("Exception thrown while looking for genre");
             Debug.Print(e.Message);
             return(false);
         }
     }
 }
示例#4
0
        private void genreEditBtn_Click(object sender, EventArgs e)
        {
            var genreForm = new GenreEdit();

            Nav(genreForm, contentPanel);
        }