public static void Delete(ApplicationDbContext context, short id) { var entity = new JGN_Comments { id = id }; context.JGN_Comments.Attach(entity); context.JGN_Comments.Remove(entity); context.SaveChanges(); }
public static JGN_Comments Process(ApplicationDbContext context, JGN_Comments entity) { if (entity.id == 0) { var userEntity = new JGN_Comments() { contentid = entity.contentid, userid = entity.userid, message = UtilityBLL.processNull(entity.message, 0), created_at = entity.created_at, isenabled = entity.isenabled, type = entity.type, points = entity.points, isapproved = entity.isapproved, levels = entity.levels, replyid = entity.replyid, replies = entity.replies }; context.Entry(userEntity).State = EntityState.Added; context.SaveChanges(); entity.id = userEntity.id; } else { var item = context.JGN_Comments .Where(p => p.id == entity.id) .FirstOrDefault <JGN_Comments>(); item.message = entity.message; context.SaveChanges(); } levelArr.Clear(); string level = prepareLevel(context, (short)entity.id); Update_Field(context, entity.id, level, "level"); return(entity); }