public ActionResult Create() { ViewBag.PageTitle = "Create Home Page Photo"; ViewBag.Title = "Create Home Page Photo"; var model = new HomePagePhotoViewModel(); return(View(model)); }
public ActionResult HomePage() { var photos = homePageService.FetchPhotos().ToList(); var model = new List <HomePagePhotoViewModel>(photos.Count); for (int i = 1; i <= photos.Count; i++) { var photo = photos[i - 1]; if (i < photos.Count) { model.Add(HomePagePhotoViewModel.ToViewModel(photo)); } else { model.Insert(0, HomePagePhotoViewModel.ToViewModel(photo)); } } return(View("_HomePage", model)); }
public ActionResult Create(HomePagePhotoViewModel model) { try { if (ModelState.IsValid) { var photo = HomePagePhotoViewModel.ToModel(model); homePageService.SavePhoto(photo); return(PartialView("_PhotoPartial", HomePagePhotoViewModel.ToViewModel(photo))); } } catch (Exception ex) { ModelState.AddModelError("", ex); this.LogError(ex); } return(Json(new { Status = MessageMode.Error, Message = "Error occurred until saving photo!" })); }