Beispiel #1
0
 public ActionResult Edit(int id)
 {
     using (var context = new SiteContext())
     {
         var company = context.Companies.First(c => c.Id == id);
         return View(company);
     }
 }
Beispiel #2
0
 public ActionResult Details(int id)
 {
     using (var context = new SiteContext())
     {
         var city = context.Cities.First(c => c.Id == id);
         return View(city);
     }
 }
Beispiel #3
0
        //
        // GET: /Admin/Company/

        public ActionResult Index()
        {
            using (var context = new SiteContext())
            {
                var companies = context.Companies.ToList();
                return View(companies);
            }
        }
Beispiel #4
0
 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");
     }
 }
Beispiel #5
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 #6
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 #7
0
        //
        // GET: /Admin/City/

        public ActionResult Index()
        {
            using(var context = new SiteContext())
            {
                var cities = context.Cities
                    //.Include("Companies")
                    .ToList()
                    ;
                return View(cities);
            }
        }
Beispiel #8
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");
     }
 }