Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using MovieApp.Models;
- using System.Data.Entity;
- using MovieApp.ViewModels;
- namespace MovieApp.Controllers
- {
- public class CustomersController : Controller
- {
- private ApplicationDbContext _context;
- public CustomersController()
- {
- _context = new ApplicationDbContext();
- }
- protected override void Dispose(bool disposing)
- {
- _context.Dispose();
- }
- public ActionResult New()
- {
- var DBmebershipTypes= _context.MembershipTypes.ToList();
- var ViewModel = new NewCustomerViewModel()
- {
- MembershipTypes = DBmebershipTypes
- };
- return View(ViewModel);
- }
- [HttpPost]
- public ActionResult Create(Customer customer)
- {
- _context.Customers.Add(customer);
- // if (customer.MembershipTypeId == null)
- // return HttpNotFound();
- _context.SaveChanges();
- return RedirectToAction("Index", "Customers");
- }
- // GET: Customers
- public ActionResult Index()
- {
- var customers = _context.Customers.Include(c => c.MembershipType).ToList();
- return View(customers);
- }
- public ActionResult Details(int id)
- {
- var customer = _context.Customers.Include(c => c.MembershipTypeId).Single(c => c.Id == id);
- return View(customer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement