public IQueryable <Category> GetCategories() { var _db = new Trojan.Models.TrojanContext(); IQueryable <Category> query = _db.Categories; return(query); }
public void UpdateVirusDescriptionDatabase(String cartId, VirusDescriptionUpdates[] CartItemUpdates) { using (var db = new Trojan.Models.TrojanContext()) { try { int CartItemCount = CartItemUpdates.Count(); List <Virus_Item> myVirus = GetDescriptionItems(); foreach (var virusItem in myVirus) { // Iterate through all rows within shopping cart list for (int i = 0; i < CartItemCount; i++) { if (virusItem.Attribute.AttributeId == CartItemUpdates[i].AttributeId) { if (CartItemUpdates[i].RemoveItem == true) { RemoveItem(cartId, virusItem.AttributeId); } else { UpdateItem(cartId, virusItem.AttributeId, CartItemUpdates[i].OnOff); } } } } } catch (Exception exp) { throw new Exception("ERROR: Unable to update Description Database - " + exp.Message.ToString(), exp); } } }
public void Dispose() { if (_db != null) { _db.Dispose(); _db = null; } }
public IQueryable<Trojan.Models.Attribute> GetAttribute([QueryString("AttributeID")] int? AttributeId) { var _db = new Trojan.Models.TrojanContext(); IQueryable<Trojan.Models.Attribute> query = _db.Attributes; if (AttributeId.HasValue && AttributeId > 0) { query = query.Where(p => p.AttributeId == AttributeId); } else { query = null; } return query; }
public bool Get_OnOff(string cartID, int AttributeId) { using (var _db = new Trojan.Models.TrojanContext()) { try { var myItem = (from c in _db.VirusDescription where c.VirusId == cartID && c.Attribute.AttributeId == AttributeId select c).FirstOrDefault(); return(myItem.On_Off); } catch (Exception exp) { throw new Exception("ERROR: Unable to query DB - " + exp.Message.ToString(), exp); } } }
public IQueryable <Trojan.Models.Attribute> GetAttribute([QueryString("AttributeID")] int?AttributeId) { var _db = new Trojan.Models.TrojanContext(); IQueryable <Trojan.Models.Attribute> query = _db.Attributes; if (AttributeId.HasValue && AttributeId > 0) { query = query.Where(p => p.AttributeId == AttributeId); } else { query = null; } return(query); }
public IQueryable <Trojan.Models.Attribute> GetAttributes([QueryString("id")] int?categoryId, [RouteData] string categoryName) { var _db = new Trojan.Models.TrojanContext(); IQueryable <Trojan.Models.Attribute> query = _db.Attributes; if (categoryId.HasValue && categoryId > 0) { query = query.Where(p => p.CategoryId == categoryId); } //if (!String.IsNullOrEmpty(categoryName)) //{ // query = query.Where(p => // String.Compare(p.Category.CategoryName, // categoryName) == 0); //} return(query); }
public IQueryable<Trojan.Models.Attribute> GetAttributes([QueryString("id")] int? categoryId, [RouteData] string categoryName) { var _db = new Trojan.Models.TrojanContext(); IQueryable<Trojan.Models.Attribute> query = _db.Attributes; if (categoryId.HasValue && categoryId > 0) { query = query.Where(p => p.CategoryId == categoryId); } //if (!String.IsNullOrEmpty(categoryName)) //{ // query = query.Where(p => // String.Compare(p.Category.CategoryName, // categoryName) == 0); //} return query; }
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); } } }
public void UpdateVirusDescriptionDatabase(String cartId, VirusDescriptionUpdates[] CartItemUpdates) { using (var db = new Trojan.Models.TrojanContext()) { try { int CartItemCount = CartItemUpdates.Count(); List<Virus_Item> myVirus = GetDescriptionItems(); foreach (var virusItem in myVirus) { // Iterate through all rows within shopping cart list for (int i = 0; i < CartItemCount; i++) { if (virusItem.Attribute.AttributeId == CartItemUpdates[i].AttributeId) { if (CartItemUpdates[i].RemoveItem == true) { RemoveItem(cartId, virusItem.AttributeId); } else { UpdateItem(cartId, virusItem.AttributeId, CartItemUpdates[i].OnOff); } } } } } catch (Exception exp) { throw new Exception("ERROR: Unable to update Description Database - " + exp.Message.ToString(), exp); } } }
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); } } }
public bool Get_OnOff(string cartID, int AttributeId) { using (var _db = new Trojan.Models.TrojanContext()) { try { var myItem = (from c in _db.VirusDescription where c.VirusId == cartID && c.Attribute.AttributeId == AttributeId select c).FirstOrDefault(); return myItem.On_Off; } catch (Exception exp) { throw new Exception("ERROR: Unable to query DB - " + exp.Message.ToString(), exp); } } }
public IQueryable<Category> GetCategories() { var _db = new Trojan.Models.TrojanContext(); IQueryable<Category> query = _db.Categories; return query; }