public ActionResult Create(CreatePlace createPlace)
 {
     if (ModelState.IsValid)
     {
         service.CreatePlace(createPlace);
         return RedirectToAction("Index").AndNotice("添加成功!");
     }
     return View(createPlace);
 }
Exemple #2
0
        public void CreatePlace(CreatePlace viewModel)
        {
            var place = new Place
            {
                Id = viewModel.Id,
                Name = viewModel.Name,
                EnglishName = viewModel.UrlKey,
                Body = viewModel.Body,
                VideoFile = FileUploads.UploadFile(viewModel.VideoFile, videoUploadDir, viewModel.UrlKey),
                VideoSize = viewModel.VideoFile.ContentLength,
                MapFile = FileUploads.UploadFile(viewModel.MapFile, mapUploadDir, viewModel.UrlKey),
                MapSize = viewModel.MapFile.ContentLength,
                MapThumbnailFile = FileUploads.UploadFile(viewModel.MapFile, mapUploadDir, string.Format("{0}-Thumbnail", viewModel.UrlKey), settings.MapThumbnailWidth)
            };

            repository.Add(place);
            SavePlace();
        }