Ejemplo n.º 1
0
 public static async Task <bool> Update(ApplicationDbContext context, JGN_Attr_Values entity)
 {
     if (entity.id > 0)
     {
         var item = context.JGN_Attr_Values
                    .Where(p => p.id == entity.id)
                    .FirstOrDefault();
         if (item != null)
         {
             item.title                = UtilityBLL.processNull(entity.title, 0);
             item.value                = string.Join(",", entity.value);
             item.priority             = (short)entity.priority;
             context.Entry(item).State = EntityState.Modified;
             await context.SaveChangesAsync();
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        public static async Task <JGN_Attr_Values> Add(ApplicationDbContext context, JGN_Attr_Values entity)
        {
            var ent = new JGN_Attr_Values()
            {
                userid    = entity.userid,
                contentid = entity.contentid,
                attr_id   = entity.attr_id,
                title     = UtilityBLL.processNull(entity.title, 0),
                value     = UtilityBLL.processNull(entity.value, 0),
                attr_type = entity.attr_type,
                priority  = entity.priority,
            };

            context.Entry(ent).State = EntityState.Added;
            await context.SaveChangesAsync();

            entity.id = ent.id;

            return(entity);
        }