public ActionResult Create()
        {
            ViewBag.PageTitle = "Create Home Page Photo";
            ViewBag.Title = "Create Home Page Photo";

            var model = new HomePagePhotoViewModel();

            return View(model);
        }
Exemple #2
0
        public static GCR.Core.Entities.HomePagePhoto ToModel(HomePagePhotoViewModel model, GCR.Core.Entities.HomePagePhoto photo = null)
        {
            if (photo == null)
            {
                photo = new GCR.Core.Entities.HomePagePhoto();
            }
            photo.DisplayOrder = model.DisplayOrder;
            photo.PhotoPath    = model.PhotoPath;

            return(photo);
        }
        public static GCR.Core.Entities.HomePagePhoto ToModel(HomePagePhotoViewModel model, GCR.Core.Entities.HomePagePhoto photo = null)
        {
            if (photo == null)
            {
                photo = new GCR.Core.Entities.HomePagePhoto();
            }
            photo.DisplayOrder = model.DisplayOrder;
            photo.PhotoPath = model.PhotoPath;

            return photo;
        }
Exemple #4
0
        public static HomePagePhotoViewModel ToViewModel(GCR.Core.Entities.HomePagePhoto photo, HomePagePhotoViewModel model = null)
        {
            if (model == null)
            {
                model = new HomePagePhotoViewModel();
            }
            model.HomePagePhotoId = photo.HomePagePhotoId;
            model.DisplayOrder    = photo.DisplayOrder;
            model.PhotoPath       = photo.PhotoPath;

            return(model);
        }
        public static HomePagePhotoViewModel ToViewModel(GCR.Core.Entities.HomePagePhoto photo, HomePagePhotoViewModel model = null)
        {
            if (model == null)
            {
                model = new HomePagePhotoViewModel();
            }
            model.HomePagePhotoId = photo.HomePagePhotoId;
            model.DisplayOrder = photo.DisplayOrder;
            model.PhotoPath = photo.PhotoPath;

            return 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!" });
        }