public ActionResult Save(TerrainFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("TerrainForm", viewModel));
            }

            if (viewModel.Id == 0)
            {
                Terrain terrain = new Terrain(viewModel.Name, viewModel.Color);
                terrainRepository.Add(terrain);
            }
            else
            {
                var terrainDb = terrainRepository.GetSingleTerrain(viewModel.Id);

                if (terrainDb == null)
                {
                    return(HttpNotFound());
                }

                terrainDb.Update(viewModel.Name, viewModel.Color);
            }

            unitOfWork.Complete();

            return(RedirectToAction("Index", "Terrain"));
        }
        public ActionResult Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var terrain = terrainRepository.GetSingleTerrain(id ?? (int)InvalidPropertyValues.undefinedValue);

            if (terrain == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new TerrainFormViewModel(terrain);

            return(View("TerrainForm", viewModel));
        }
        public ActionResult New()
        {
            var viewModel = new TerrainFormViewModel();

            return(View("TerrainForm", viewModel));
        }