public static void Delete(ApplicationDbContext context, short id) { var entity = new JGN_BadgeCategories { id = id }; context.JGN_BadgeCategories.Attach(entity); context.JGN_BadgeCategories.Remove(entity); context.SaveChanges(); }
public static JGN_BadgeCategories Update(ApplicationDbContext context, JGN_BadgeCategories entity) { var item = context.JGN_BadgeCategories .Where(p => p.id == entity.id) .FirstOrDefault <JGN_BadgeCategories>(); item.title = entity.title; item.description = entity.description; item.shorttitle = entity.shorttitle; item.type = (byte)entity.type; item.priority = entity.priority; context.SaveChanges(); context.Entry(item).State = EntityState.Modified; context.SaveChanges(); return(entity); }
public static JGN_BadgeCategories Add(ApplicationDbContext context, JGN_BadgeCategories entity) { var _ga = new JGN_BadgeCategories() { title = entity.title, description = entity.description, shorttitle = entity.shorttitle, type = (byte)entity.type, priority = entity.priority, }; context.Entry(_ga).State = EntityState.Added; context.SaveChanges(); entity.id = _ga.id; return(entity); }