public IActionResult AddPage(AddPageViewModel model) { if (!ModelState.IsValid) { ViewData["GeneralError"] = Messages.RequiredInput; return(View(model)); } var source = _galleryService.UploadGalleryImage(model.File, ImageSavePaths.PageSavePath); if (source.Success) { Page page = new Page { Title = model.Title, Description = model.Description, Image = source.Data, Type = model.Type, Text = model.Text }; var result = _pageService.Add(page); if (result.Success) { ViewData["GeneralSuccess"] = result.Message; return(RedirectToAction("ListPage", "ManagementPanel")); } } ViewData["GeneralError"] = Messages.GeneralError; return(View(model)); }
public virtual async Task <ActionResult> Add() { var model = new AddPageViewModel { Pages = await _pageService.GetAllPagesForAdd() }; return(View(model)); }
static Navigation() { LoginViewModel = new LoginPageViewModel(new LoginPage()); RegisterViewModel = new RegisterPageViewModel(new RegisterPage()); AddViewModel = new AddPageViewModel(new NoteInfoPage()); EditViewModel = new EditPageViewModel(new NoteInfoPage()); InfoViewModel = new NoteInfoViewModel(new NoteInfoPage()); }
public IActionResult Add(AddPageViewModel model) { if (ModelState.IsValid) { _indexingService.IndexPage(model.Url); RedirectToAction("Index"); } return(View(model)); }
public ActionResult Create() { var model = new AddPageViewModel { Categories = this.populator.GetCategories() }; return this.View(model); }
public ActionResult Create() { var model = new AddPageViewModel { Categories = this.populator.GetCategories() }; return(this.View(model)); }
public AddPage() { ViewModel = IoC.Get <AddPageViewModel>(); this.InitializeComponent(); NavigationHelper = new NavigationHelper(this); NavigationHelper.LoadState += this.NavigationHelper_LoadState; NavigationHelper.SaveState += this.NavigationHelper_SaveState; }
public AddPage() { InitializeComponent(); Context = this.BindingContext as AddPageViewModel; bingSpeechService = new BingSpeechService(new AuthenticationService(Constants.BingSpeechApiKey), Device.RuntimePlatform); bingSpellCheckService = new BingSpellCheckService(); textTranslationService = new TextTranslationService(new AuthenticationService(Constants.TextTranslatorApiKey)); audioRecordingService = new AudioRecorderService(); }
public ActionResult AddPage(AddPageViewModel model) { if (ModelState.IsValid) { var page = new Page(model.Title, model.Description, model.Content, model.Password); dataManger.AddPage(page); dataManger.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(model)); }
public virtual async Task <ActionResult> Create(AddPageViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } viewModel.Content = viewModel.Content.ToSafeHtml(); if (_pageService.Add(viewModel)) { await _unitOfWork.SaveChangesAsync(); CacheManager.InvalidateChildActionsCache(); return(RedirectToAction(MVC.Admin.Page.ActionNames.Create, MVC.Admin.Page.Name)); } ModelState.AddModelError("Title", "چنین صفحه ای قبلا ثبت شده است"); return(View(viewModel)); }
public bool Add(AddPageViewModel viewModel) { if (ExistByTitle(viewModel.Title)) { return(false); } var page = new Page { Content = viewModel.Content, Description = viewModel.Description, ImagePath = viewModel.ImagePath, KeyWords = viewModel.KeyWords, PageShowPlace = viewModel.PageShowPlace, Title = viewModel.Title, DisplayOrder = viewModel.DisplayOrder }; _pages.Add(page); return(true); }
public virtual async Task <ActionResult> Add(AddPageViewModel pageModel) { if (!ModelState.IsValid) { pageModel.Pages = await _pageService.GetAllPagesForAdd(); return(View(pageModel)); } var page = new DomainClasses.Page() { PostedByUserId = User.Identity.GetUserId <int>() }; _mappingEngine.Map(pageModel, page); if (pageModel.Id.HasValue) { _pageService.EditPage(page, pageModel.Pages.Select(x => new DomainClasses.Page { Id = x.Id ?? 0, Order = x.Order }).ToList()); TempData["message"] = "برگه مورد نظر با موفقیت ویرایش شد"; } else { _pageService.AddPage(page, pageModel.Pages.Select(x => new DomainClasses.Page { Id = x.Id ?? 0, Order = x.Order }).ToList()); TempData["message"] = "برگه جدید با موفقیت در سیستم ثبت شد"; } await _unitOfWork.SaveAllChangesAsync(); return(RedirectToAction(MVC.Page.Admin.ActionNames.Index)); }
public async Task <IActionResult> AddPage(AddPageViewModel model) { if (ModelState.IsValid) { Page page = new Page() { Id = Guid.NewGuid(), PageTitle = model.PageTitle, PageBody = SpecSymbolsToView(model.PageBody), // Замена символов на их безопасные шестнадцатеричные значения PageDate = DateTime.Now, UserName = "******" // Хардкод. Потом обязательно заменить !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! }; await cmsDB.Pages.AddAsync(page); await cmsDB.SaveChangesAsync(); return(RedirectToAction("ViewPage", "Page", new { pageId = page.Id })); } return(View(model)); }
public AddPage(UserModel user) { InitializeComponent(); BindingContext = new AddPageViewModel(this, Navigation, user); }
public AddPage() { InitializeComponent(); BindingContext = new AddPageViewModel(); }
public ActionResult Create(AddPageViewModel model) { if (model != null && ModelState.IsValid) { var page = AutoMapper.Mapper.Map<Page>(model); page.Description = this.sanitizer.Sanitize(model.Description); page.UserId = this.CurrentUser.Id; page.CreatedOn = DateTime.Now; if (model.UploadedImage != null) { page.Image = this.GetUploadedImage(model as IHaveImage); } if (model.CategoryId == -1) { page.CategoryId = this.data.Categories.All().FirstOrDefault(c => c.Name == "Other").Id; } this.data.Pages.Add(page); this.data.SaveChanges(); model.Id = page.Id; model.Categories = this.populator.GetCategories(); if (model.TagsString != null) { var tags = model.TagsString.Split(this.tagSeparators, StringSplitOptions.RemoveEmptyEntries); foreach (var tag in tags) { page.Tags.Add(new Tag { Name = tag }); } } if (model.IsLike == true) { page.Likes.Add(new Like { UserId = page.UserId }); } else { page.Dislikes.Add(new Dislike { UserId = page.UserId }); } page.Rating = this.GetPageRating(page); this.data.SaveChanges(); return this.RedirectToAction("Details", new { id = page.Id }); } return this.View(model); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters //Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are being GPU accelerated with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; } // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // setup container var state = new ApplicationState(); var commandBus = new CommandBus(); var mainViewModel = new MainViewModel(); var addPageViewModel = new AddPageViewModel(); _initializationAction = (IContainer x) => { x.Register <ISettingsManager, SettingsManager>(); x.Register <IStorageManager, StorageManager>(); x.Register <IUIThreadInvoker, UIThreadInvoker>(); x.Register <ICommandBus>(commandBus); x.Register <IApplicationState>(state); x.Register <INavigationServiceWrapper, NavigationServiceWrapper>(); x.Register <IDialogService, DialogService>(); x.Register <ITrialService, TrialService>(); x.Register <ICommandHandler <ApplicationLoadedCommand>, ApplicationLoadedCommandHandler>(); x.Register <ICommandHandler <MainPageLoadedCommand>, MainPageLoadedCommandHandler>(); x.Register <ICommandHandler <AddNewShortCodeCommand>, AddNewShortCodeCommandHandler>(); x.Register <ICommandHandler <EditShortCodeCommand>, EditShortCodeCommandHandler>(); x.Register <ICommandHandler <SaveShortCodeCommand>, SaveShortCodeCommandHandler>(); x.Register <ICommandHandler <DeleteShortCodeCommand>, DeleteShortCodeCommandHandler>(); x.Register <ICommandHandler <SendSmsCommand>, SendSmsCommandHandler>(); x.Register <ICommandHandler <DataLoadedMessage>, DataLoadedCommandHandler>(); x.Register <IValidator <ShortCode>, ShortCodeValidator>(); x.Register <IMainViewModel>(mainViewModel); x.Register <IAddPageViewModel>(addPageViewModel); }; MicroMap.Initialize(_initializationAction); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <ApplicationLoadedCommand> >()); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <MainPageLoadedCommand> >()); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <AddNewShortCodeCommand> >()); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <EditShortCodeCommand> >()); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <SaveShortCodeCommand> >()); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <DeleteShortCodeCommand> >()); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <SendSmsCommand> >()); commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <DataLoadedMessage> >()); }
public AddPageView(AddPageViewModel viewModel) { this.DataContext = viewModel; InitializeComponent(); }
public ActionResult Create(AddPageViewModel model) { if (model != null && ModelState.IsValid) { var page = AutoMapper.Mapper.Map <Page>(model); page.Description = this.sanitizer.Sanitize(model.Description); page.UserId = this.CurrentUser.Id; page.CreatedOn = DateTime.Now; if (model.UploadedImage != null) { page.Image = this.GetUploadedImage(model as IHaveImage); } if (model.CategoryId == -1) { page.CategoryId = this.data.Categories.All().FirstOrDefault(c => c.Name == "Other").Id; } this.data.Pages.Add(page); this.data.SaveChanges(); model.Id = page.Id; model.Categories = this.populator.GetCategories(); if (model.TagsString != null) { var tags = model.TagsString.Split(this.tagSeparators, StringSplitOptions.RemoveEmptyEntries); foreach (var tag in tags) { page.Tags.Add(new Tag { Name = tag }); } } if (model.IsLike == true) { page.Likes.Add(new Like { UserId = page.UserId }); } else { page.Dislikes.Add(new Dislike { UserId = page.UserId }); } page.Rating = this.GetPageRating(page); this.data.SaveChanges(); return(this.RedirectToAction("Details", new { id = page.Id })); } return(this.View(model)); }