public ActionResult Edit(int id) { using (var context = new SiteContext()) { var company = context.Companies.First(c => c.Id == id); return View(company); } }
public ActionResult Details(int id) { using (var context = new SiteContext()) { var city = context.Cities.First(c => c.Id == id); return View(city); } }
// // GET: /Admin/Company/ public ActionResult Index() { using (var context = new SiteContext()) { var companies = context.Companies.ToList(); return View(companies); } }
public ActionResult Delete(int id) { using (var context = new SiteContext()) { var city = context.Cities.First(c => c.Id == id); context.Cities.Remove(city); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Edit(City model) { using (var context = new SiteContext()) { var city = context.Cities.First(c => c.Id == model.Id); TryUpdateModel(city, new[] { "Name", "Title", "IsActive" }); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Create(City model) { using (var context = new SiteContext()) { var city = new City(); TryUpdateModel(city, new[] {"Name", "Title", "IsActive"}); context.Cities.Add(city); context.SaveChanges(); return RedirectToAction("Index"); } }
// // GET: /Admin/City/ public ActionResult Index() { using(var context = new SiteContext()) { var cities = context.Cities //.Include("Companies") .ToList() ; return View(cities); } }
public ActionResult Create(City model) { using (var context = new SiteContext()) { var company = new Company(); TryUpdateModel(company, new[] { "Name", "Title", "IsActive","Description","ImageSource" }); context.Companies.Add(company); context.SaveChanges(); return RedirectToAction("Index"); } }