public void AddPizzaToCart(Cart CartObj) { var returnedObj = context.Carts.FirstOrDefault(t => t.OrderedBy == CartObj.OrderedBy && t.ProductId == CartObj.ProductId); if (returnedObj == null) { CartObj.Quantity = 1; context.Carts.Add(CartObj); } else { returnedObj.Quantity++; } context.SaveChanges(); }
/// <summary> /// This method registers a new user /// </summary> /// <param name="userObj">Object of user type that need to be registered</param> public void RegisterUser(User userObj) { context.Users.Add(userObj); context.SaveChanges(); }