Ejemplo n.º 1
0
 public static async Task <bool> Update(ApplicationDbContext context, JGN_Attr_Attributes entity)
 {
     if (entity.id > 0)
     {
         var item = context.JGN_Attr_Attributes
                    .Where(p => p.id == entity.id)
                    .FirstOrDefault();
         if (item != null)
         {
             item.title                = UtilityBLL.processNull(entity.title, 0);
             item.value                = string.Join(",", entity.value);
             item.options              = UtilityBLL.processNull(entity.options, 0);
             item.priority             = (short)entity.priority;
             item.element_type         = entity.element_type;
             item.isrequired           = entity.isrequired;
             item.variable_type        = entity.variable_type;
             item.icon                 = entity.icon;
             item.min                  = entity.min;
             item.max                  = entity.max;
             item.postfix              = UtilityBLL.processNull(entity.postfix, 0);
             item.prefix               = UtilityBLL.processNull(entity.prefix, 0);
             item.tooltip              = UtilityBLL.processNull(entity.tooltip, 0);
             item.url                  = UtilityBLL.processNull(entity.url, 0);
             item.helpblock            = UtilityBLL.processNull(entity.helpblock, 0);
             context.Entry(item).State = EntityState.Modified;
             await context.SaveChangesAsync();
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        public static async Task <JGN_Attr_Attributes> Add(ApplicationDbContext context, JGN_Attr_Attributes entity)
        {
            var ent = new JGN_Attr_Attributes()
            {
                title         = UtilityBLL.processNull(entity.title, 0),
                value         = UtilityBLL.processNull(entity.value, 0),
                options       = UtilityBLL.processNull(entity.options, 0),
                sectionid     = entity.sectionid,
                priority      = entity.priority,
                attr_type     = entity.attr_type,
                element_type  = entity.element_type,
                isrequired    = entity.isrequired,
                variable_type = entity.variable_type,
                min           = entity.min,
                max           = entity.max,
                postfix       = UtilityBLL.processNull(entity.postfix, 0),
                prefix        = UtilityBLL.processNull(entity.prefix, 0),
                tooltip       = UtilityBLL.processNull(entity.tooltip, 0),
                url           = UtilityBLL.processNull(entity.url, 0),
                helpblock     = UtilityBLL.processNull(entity.helpblock, 0),
                icon          = entity.icon
            };

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

            await context.SaveChangesAsync();

            entity.id = ent.id;
            return(entity);
        }