예제 #1
0
        public ActionResult Create()
        {
            ViewBag.PageTitle = "Create Home Page Photo";
            ViewBag.Title = "Create Home Page Photo";

            var model = new HomePagePhotoViewModel();

            return View(model);
        }
예제 #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);
        }
예제 #3
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;
        }
예제 #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);
        }
예제 #5
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;
        }
예제 #6
0
        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!" });
        }