public static async Task <JGN_Attr_Templates> Add(ApplicationDbContext context, JGN_Attr_Templates entity) { var ent = new JGN_Attr_Templates() { title = UtilityBLL.processNull(entity.title, 0), attr_type = entity.attr_type }; context.Entry(ent).State = EntityState.Added; await context.SaveChangesAsync(); entity.id = ent.id; return(entity); }
public static async Task <bool> Update(ApplicationDbContext context, JGN_Attr_Templates entity) { if (entity.id > 0) { var item = context.JGN_Attr_Templates .Where(p => p.id == entity.id) .FirstOrDefault(); if (item != null) { item.title = UtilityBLL.processNull(entity.title, 0); context.Entry(item).State = EntityState.Modified; await context.SaveChangesAsync(); } } return(true); }