public static bool AddList(LAList list) { bool success = false; if (list.Name != null) { var duplicate = db.LALists.Where(e => e.Name.Equals(list.Name)).FirstOrDefault(); if (duplicate == null) { db.LALists.Add(list); db.SaveChanges(); success = true; } } return(success); }
public int AddList(string listName) { int id = 0; if (listName != null) { var duplicate = db.LALists.Where(e => e.Name.Equals(listName)).FirstOrDefault(); if (duplicate == null) { var ShoppingList = new LAList(); ShoppingList.Name = listName; db.LALists.Add(ShoppingList); db.SaveChanges(); id = ShoppingList.ID; } } return(id); }