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

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

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