public static void Delete(ApplicationDbContext context, int id) { var entity = new JGN_Packages { id = (byte)id }; context.JGN_Packages.Attach(entity); context.JGN_Packages.Remove(entity); context.SaveChanges(); }
// Important Terms: // isenabled // 0: ............... : Disabled Package // 1: ............... : Enabled Package // Price // 0 ............... : Free // Any Vlue ........ : // Type // 0.................: Apply on all content types // any value ........: Apply on specific content types (0: video, 1: audio, 2: galleries, 3: photos, 4: blogs) // Credits // Any value ................: use to purchase premium contents // Package Type // ...................... 0: Free Packages // ...................... 1: Paid Packages // ...................... 2: UserBLLhip Subscription public static JGN_Packages Process(ApplicationDbContext context, JGN_Packages entity) { if (entity.id == 0) { var _entity = new JGN_Packages() { name = entity.name, description = entity.description, isenabled = entity.isenabled, price = entity.price, created_at = DateTime.Now, type = entity.type, credits = entity.credits, package_type = entity.package_type, currency = entity.currency, months = entity.months, discount = entity.discount }; context.Entry(_entity).State = EntityState.Added; context.SaveChanges(); entity.id = _entity.id; } else { var item = context.JGN_Packages .Where(p => p.id == entity.id) .FirstOrDefault <JGN_Packages>(); if (item != null) { item.name = entity.name; item.description = entity.description; item.isenabled = entity.isenabled; item.price = entity.price; item.type = entity.type; item.credits = entity.credits; item.package_type = entity.package_type; item.currency = entity.currency; item.months = entity.months; item.discount = entity.discount; context.SaveChanges(); } } return(entity); }