コード例 #1
0
        public virtual BannerModel PrepareBannerModel(Banner banner)
        {
            var model = banner.ToModel();

            //string status = Enum.GetName(typeof(BannerStatus), banner.Status);
            BannerStatus status = (BannerStatus)Enum.Parse(typeof(BannerStatus), banner.Status.ToString());

            model.AvailableBannerStatuses = status.ToSelectList(true).ToList();

            BannerType type = (BannerType)Enum.Parse(typeof(BannerType), banner.Type.ToString());

            model.AvailableBannerTypes = type.ToSelectList(true).ToList();

            return(model);
        }
コード例 #2
0
        public virtual ActionResult Edit(BannerModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageBanner))
            {
                return(AccessDeniedView());
            }

            var banner = _bannerService.GetBannerById(model.Id);

            if (ModelState.IsValid)
            {
                banner = model.ToEntity(banner);
                banner.Pictures.First().PictureId = model.PictureModel.PictureId;

                _bannerService.UpdateBanner(banner);


                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return(RedirectToAction("Edit", new { id = banner.Id }));
                }
                return(RedirectToAction("List"));
            }

            //model = _bannerModelFactory.PrepareBannerModel(banner);

            BannerStatus status = (BannerStatus)Enum.Parse(typeof(BannerStatus), banner.Status.ToString());

            model.AvailableBannerStatuses = status.ToSelectList(true).ToList();

            BannerType type = (BannerType)Enum.Parse(typeof(BannerType), banner.Type.ToString());

            model.AvailableBannerTypes = type.ToSelectList(true).ToList();

            return(View(model));
        }