public ActionResult Create(Area area)
        {
            if (ModelState.IsValid)
            {
                db.Areas.Add(area);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(area);
        }
        public ActionResult AddAreas()
        {
            // Get session data that was passed via TempData
            _files = TempData["Areas"] as List<string>;
            //      Get list of processedfiles, if null, init new list
            var processedFiles = TempData["ProcessedAreas"] as List<Area> ?? new List<Area>();

            // Populate dropdown list
            var areaList = db.Areas.ToList();
            var areaDropDown = areaList.Select(item => new SelectListItem
                {
                    Text = item.Name, Value = item.ID.ToString(CultureInfo.InvariantCulture)
                }).ToList();
            var selectList = new SelectList(areaDropDown, "Value", "Text");
            ViewBag.AreaList = selectList;

            // Process next file in list
            if (_files != null && _files.Count > 0)
            {
                var nextarea = _files[0];
                var area = new Area()
                    {
                        Are = System.IO.File.ReadAllBytes(Server.MapPath("~/App_Data/uploads/temp/") + nextarea + ".are"),
                        Gic = System.IO.File.ReadAllBytes(Server.MapPath("~/App_Data/uploads/temp/") + nextarea + ".gic"),
                        Git = System.IO.File.ReadAllBytes(Server.MapPath("~/App_Data/uploads/temp/") + nextarea + ".git"),
                        LastModified = DateTime.Now,
                        Oldresref = nextarea,
                        Name = nextarea,
                        Tags = "",
                        Uploaded = DateTime.Now
                    };
                // Remove from list so we know it's processed
                _files.RemoveAt(0);
                // Add to list of processed areas
                processedFiles.Add(area);

                // Pass Tempdata onto next view
                TempData["ProcessedAreas"] = processedFiles;
                TempData["Areas"] = _files;

                // Add count of areas and how many processed (example: Area 1 of 3)
                ViewBag.CurrentArea = processedFiles.Count;
                ViewBag.TotalAreas = processedFiles.Count + _files.Count;

                return View(area);
            }
            return View();
        }
 public ActionResult Edit(Area area)
 {
     if (ModelState.IsValid)
     {
         db.Entry(area).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(area);
 }