Example #1
0
        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();
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }