Beispiel #1
0
 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");
     }
 }
Beispiel #2
0
 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");
     }
 }
Beispiel #3
0
 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");
     }
 }