public void UpdateItem(string updateCartID, int updateAttributeId, bool OnOff) { using (var _db = new Trojan.Models.TrojanContext()) { try { var myItem = (from c in _db.VirusDescription where c.VirusId == updateCartID && c.Attribute.AttributeId == updateAttributeId select c).FirstOrDefault(); if (myItem != null) { myItem.On_Off = OnOff; _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to update decription - " + exp.Message.ToString(), exp); } } }
public void RemoveItem(string removeCartID, int removeAttributeId) { using (var _db = new Trojan.Models.TrojanContext()) { try { var myItem = (from c in _db.VirusDescription where c.VirusId == removeCartID && c.Attribute.AttributeId == removeAttributeId select c).FirstOrDefault(); if (myItem != null) { // Remove Item. _db.VirusDescription.Remove(myItem); _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Remove Description Item - " + exp.Message.ToString(), exp); } } }