Пример #1
0
 public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
 {
     var errors = new List<ValidationResult>();
     var service = new PageService(new EKProvider());
     if ((this.Inserting()  || (!Inserting() && service.GetPage(this.Page.PageNavigation.Id).PageNavigation.PagePath().ToLower() != this.Page.PageNavigation.PagePath().ToLower())) && service.GetNavigation().Any(p => p.PagePath().ToLower() == this.Page.PageNavigation.PagePath().ToLower()))
         errors.Add(new ValidationResult("Page title is currently being used", new string[]{"Page.PageNavigation.Title"}));
     return errors;
 }
        public static HomeIndexViewModel Create(int? id, PageService service)
        {
            var page = id.HasValue ? service.GetPage(id.Value) : service.GetHomePage();

            return new HomeIndexViewModel
                       {
                           Page = page,
                           Pages = service.GetNavigation(),
                           Site = service.GetSite()
                       };
        }
Пример #3
0
        public object BindModel(ControllerContext ctx, ModelBindingContext modelCtx)
        {
            var service = new PageService(new EKProvider());
            int? id = null;
            var userMode = false;
            if (modelCtx.ValueProvider.GetValue("NavigationModel.Page.Id") != null)
                id = int.Parse(modelCtx.ValueProvider.GetValue("NavigationModel.Page.Id").AttemptedValue);
            else if (modelCtx.ValueProvider.GetValue("id") != null)
                id = int.Parse(modelCtx.ValueProvider.GetValue("id").AttemptedValue);
            else if (modelCtx.ValueProvider.GetValue("pageTitle") != null && service.GetNavigation().FirstOrDefault(p => modelCtx.ValueProvider.GetValue("pageTitle").AttemptedValue == p.PagePath()) != null)
            {
                id = service.GetNavigation().First(p => modelCtx.ValueProvider.GetValue("pageTitle").AttemptedValue == p.PagePath()).Id;
            }
            if (modelCtx.ValueProvider.GetValue("UserMode") != null)
                userMode = bool.Parse(modelCtx.ValueProvider.GetValue("UserMode").AttemptedValue);
            var model = HomeIndexViewModelLoader.Create(id, new PageService(new EKProvider()));
            model.UserMode = userMode;
            return model;

            return null;
        }
Пример #4
0
 public AuthController(IEKProvider dal)
 {
     _service = new PageService(dal);
 }
Пример #5
0
 public BaseAdminController(IEKProvider provider)
     : base(provider)
 {
     _service = new PageService(provider);
 }
Пример #6
0
 public BaseController(IEKProvider provider)
 {
     _service = new PageService(provider);
     ViewBag.Service = _service;
 }