public IActionResult Create(Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public IActionResult Create(Experience experience) { db.Experiences.Add(experience); //var thisPersonId = Int32.Parse(Request.Form["PersonId"]); //var thisPerson = db.People.FirstOrDefault(People => People.PersonId == thisPersonId); //thisPerson.ExperienceId = experience.ExperienceId; //var thisExperiencePeople = new ExperiencePeople{}; //thisExperiencePeople.ExperienceId = experience.ExperienceId; //thisExperiencePeople.PersonId = thisPerson.PersonId; //db.ExperiencePeople.Add(thisExperiencePeople); //db.Entry(thisPerson).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult DeleteConfirmed(int id) { Review thisReview = reviewRepo.Reviews.FirstOrDefault(items => items.ReviewId == id); reviewRepo.Remove(thisReview); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void Initialize(GummiDbContext context) { if (context.Products.Any()) { return; } var products = new Product[] { new Product() { Name = "Giant Gummi", Description = "12 oz. gummi bear", Cost = 499 }, new Product() { Name = "Green Gummies", Description = "16 oz. bag of green gummi bears", Cost = 6 }, new Product() { Name = "Glitter Gummies", Description = "16 oz. bag of pink and purple glittery gummi bears", Cost = 8 }, new Product() { Name = "Shark Gummies", Description = "8 0z. bag of shark gummies", Cost = 4 }, new Product() { Name = "Gummi Worms", Description = "16 oz. bag of rainbow colored gummi worms", Cost = 6 }, new Product() { Name = "Red Hot Gummies", Description = "16 oz. bag of red hot gummi bears", Cost = 3 }, }; foreach (Product p in products) { context.Products.Add(p); } context.SaveChanges(); }
public IActionResult Create(Review review) { db.Reviews.Add(review); db.SaveChanges(); return(RedirectToAction("Index")); }
public Product Save(Product product) { db.Products.Add(product); db.SaveChanges(); return(product); }
public IActionResult Create(Gummi gummi) { db.Gummis.Add(gummi); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(User user) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); }
public Review Save(Review product) { db.Reviews.Add(product); db.SaveChanges(); return(product); }
public Review Save(Review review) { db.Reviews.Add(review); db.SaveChanges(); return(review); }
public IActionResult Create(Product item) { db.Products.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(Category item) { db.Categories.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(Location location) { db.Locations.Add(location); db.SaveChanges(); return(RedirectToAction("Index")); }