Exemple #1
0
 public ActionResult Remove(ColorEditViewModel model, int colorIdx)
 {
     ModelState.Clear();
     model.NavigationModel = HomeIndexViewModelLoader.Create(model.NavigationModel.Page.PageNavigation.Id, _service);
     model.Colors.RemoveAt(colorIdx);
     return(View("Edit", model));
 }
Exemple #2
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);
        }
        public ActionResult ChangePassword(int id)
        {
            var model = new PasswordChangeViewModel {
            };

            model.NavigationModel = HomeIndexViewModelLoader.Create(id, _service);
            return(View(model));
        }
Exemple #4
0
 public ActionResult Add(ColorEditViewModel model)
 {
     ModelState.Clear();
     model.NavigationModel = HomeIndexViewModelLoader.Create(model.NavigationModel.Page.PageNavigation.Id, _service);
     model.Colors.Add(new EKContent.web.Models.Entities.Color {
     });
     return(View("Edit", model));
 }
        public ActionResult Edit(int id)
        {
            var model = new SiteEditViewModel {
                Site = _service.GetSite()
            };

            model.NavigationModel = HomeIndexViewModelLoader.Create(id, _service);
            return(View(model));
        }
        public ActionResult EditTwitterKeys(int id)
        {
            var model = new TwitterKeysEditViewModel {
                TwitterKeys = _service.GetTwitterKeys()
            };

            model.NavigationModel = HomeIndexViewModelLoader.Create(id, _service);
            return(View(model));
        }
Exemple #7
0
        public ActionResult Edit(int id)
        {
            var model = new ColorEditViewModel {
                Colors = _service.Dal.ColorProvider.Get()
            };

            model.NavigationModel = HomeIndexViewModelLoader.Create(id, _service);
            return(View(model));
        }
Exemple #8
0
        public ActionResult Edit(int id)
        {
            var model = new StyleSettingsEditViewModel {
            };

            model.Settings        = _service.StylesProvider().VariablesList();
            model.Colors          = _service.Dal.ColorProvider.Get();
            model.NavigationModel = HomeIndexViewModelLoader.Create(id, _service);
            return(View(model));
        }
        public ActionResult Create(int pageId, int?id)
        {
            var image = id.HasValue ? _service.GetImages().Single(i => i.Id == id.Value) : new Image {
            };
            var model = new ImageCreateViewModel {
                Image = image
            };

            model.NavigationModel = HomeIndexViewModelLoader.Create(pageId, _service);
            return(View(model));
        }
Exemple #10
0
        public ActionResult Create(int pageId, int?id)
        {
            var file  = id.HasValue ? _service.Dal.FileProvider.Get().Single(i => i.Id == id.Value) : new EKFile {
            };
            var model = new FileCreateViewModel {
                File = file
            };

            model.NavigationModel = HomeIndexViewModelLoader.Create(pageId, _service);
            return(View(model));
        }
 public ActionResult Login(LoginViewModel model)
 {
     if (!Membership.ValidateUser(model.Username, model.Password))
     {
         ModelState.AddModelError("", "Username and/or Password are incorrect");
         model.NavigationModel = HomeIndexViewModelLoader.Create(model.NavigationModel.Page.PageNavigation.Id, _service);
         return(View(model));
     }
     else
     {
         FormsAuthentication.SetAuthCookie(model.Username, false);
         return(RedirectToAction("Index", "Home", new { id = model.NavigationModel.Page.PageNavigation.Id }));
     }
 }
Exemple #12
0
        public ActionResult EditContent(int Idx, int pageId, int Mdx)
        {
            var page  = _service.GetPage(pageId);
            var model = new EditContentItemViewModel
            {
                Mdx             = Mdx,
                Idx             = Idx,
                NavigationModel = HomeIndexViewModelLoader.Create(pageId, _service),
                Images          = _service.GetImages(),
                Files           = _service.Dal.FileProvider.Get()
            };

            model.Content = model.Inserting() ? new Content {
            } : page.Modules[Mdx].Content[Idx];
            return(View(model));
        }
        public ActionResult ChangePassword(PasswordChangeViewModel model)
        {
            model.NavigationModel = HomeIndexViewModelLoader.Create(model.NavigationModel.Page.PageNavigation.Id, _service);
            if (!Membership.ValidateUser(Membership.GetUser().UserName, model.OldPassword))
            {
                ModelState.AddModelError("OldPassword", "Incorrect Password");
            }
            ModelState["NavigationModel.Page.Title"].Errors.Clear();
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = Membership.GetUser();

            user.ChangePassword(model.OldPassword, model.NewPassword);
            TempData["message"] = "Password has been changed";
            return(RedirectToAction("Index", "Home", new { id = model.NavigationModel.Page.PageNavigation.Id }));
        }
Exemple #14
0
        public ActionResult EditPage(int?pageId, int?parentId)
        {
            var id    = pageId.HasValue ? pageId.Value : parentId.Value;
            var page  = _service.GetPage(id);
            var model = new EditPageViewModel
            {
                ParentId        = parentId,
                PageId          = pageId,
                NavigationModel = HomeIndexViewModelLoader.Create(id, _service)
            };

            model.Page = model.Inserting() ? new Page {
                PageNavigation = new PageNavigation {
                    ParentId = parentId
                }
            } : page;
            return(View(model));
        }
Exemple #15
0
        public ActionResult EditContent(EditContentItemViewModel model)
        {
            //if (String.IsNullOrEmpty(model.Content.Body))
            //    ModelState.AddModelError("Content.Body", "Required");
            if (ModelState.IsValid)
            {
                var content = model.Inserting() ? new Content {
                } : model.NavigationModel.Page.Modules[model.Mdx].Content[model.Idx];
                if (model.Inserting())
                {
                    if (model.NavigationModel.Page.Modules.Count == 0)
                    {
                        model.NavigationModel.Page.Modules.Add(new Module {
                        });
                    }
                    model.NavigationModel.Page.Modules[model.Mdx].Content.Add(content);
                }

                content.Title         = model.Content.Title;
                content.Body          = model.Content.Body;
                content.ShowTitle     = model.Content.ShowTitle;
                content.Priority      = model.Content.Priority;
                content.ImageId       = model.Content.ImageId;
                content.FileId        = model.Content.FileId;
                content.DatePublished = model.Content.DatePublished;
                content.ShowAddThis   = model.Content.ShowAddThis;
                content.BorderImage   = model.Content.BorderImage;
                _service.SavePage(model.NavigationModel.Page);
                Message("Content Saved");
                return(RedirectToAction("Index", new { id = model.NavigationModel.Page.PageNavigation.Id }));
            }
            model.Images          = _service.GetImages();
            model.Files           = _service.Dal.FileProvider.Get();
            model.NavigationModel = HomeIndexViewModelLoader.Create(model.NavigationModel.Page.PageNavigation.Id, _service);
            return(View(model));
        }