public virtual IActionResult Create(PollModel model, bool continueEditing) { if (ModelState.IsValid) { Poll poll = model.ToEntity <Poll>(); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.InsertPoll(poll); SuccessNotification("Yeni Anket Eklendi"); if (!continueEditing) { return(RedirectToAction("List")); } //selected tab SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = poll.Id })); } //prepare model model = _pollModelFactory.PreparePollModel(model, null, true); //if we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Edit(PollModel model, bool continueEditing) { var poll = _pollService.GetPollById(model.Id); if (poll == null) { return(RedirectToAction("List")); } if (ModelState.IsValid) { poll = model.ToEntity(poll); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.UpdatePoll(poll); SaveStoreMappings(poll, model.SelectedStoreIds); NotifySuccess(T("Admin.ContentManagement.Polls.Updated")); return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List")); } // If we got this far, something failed, redisplay form. PreparePollModel(model, poll, true); return(View(model)); }
public ActionResult Edit(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } var poll = _pollService.GetPollById(model.Id); if (poll == null) { return(RedirectToAction("List")); } if (ModelState.IsValid) { poll = model.ToEntity(poll); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.UpdatePoll(poll); _storeMappingService.SaveStoreMappings <Poll>(poll, model.SelectedStoreIds); NotifySuccess(_localizationService.GetResource("Admin.ContentManagement.Polls.Updated")); return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); PreparePollModel(model, poll, true); return(View(model)); }
public virtual ActionResult Create(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var poll = model.ToEntity(); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.InsertPoll(poll); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Added")); if (continueEditing) { //selected tab SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = poll.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form PrepareLanguagesModel(model); return(View(model)); }
public virtual IActionResult Create(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var poll = model.ToEntity <Poll>(); _pollService.InsertPoll(poll); //save store mappings SaveStoreMappings(poll, model); _notificationService.SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Added")); if (!continueEditing) { return(RedirectToAction("List")); } return(RedirectToAction("Edit", new { id = poll.Id })); } //prepare model model = _pollModelFactory.PreparePollModel(model, null, true); //if we got this far, something failed, redisplay form return(View(model)); }
public IActionResult Create(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var poll = model.ToEntity(); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; poll.Stores = model.SelectedStoreIds != null?model.SelectedStoreIds.ToList() : new List <string>(); poll.CustomerRoles = model.SelectedCustomerRoleIds != null?model.SelectedCustomerRoleIds.ToList() : new List <string>(); poll.Locales = UpdateLocales(poll, model); _pollService.InsertPoll(poll); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); //Stores PrepareStoresMappingModel(model, null, true); //locales AddLocales(_languageService, model.Locales); //ACL PrepareAclModel(model, null, true); return(View(model)); }
public ActionResult Create(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var poll = model.ToEntity(); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.InsertPoll(poll); SaveStoreMappings(poll, model); NotifySuccess(T("Admin.ContentManagement.Polls.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List")); } // If we got this far, something failed, redisplay form. PreparePollModel(model, null, true); return(View(model)); }
public ActionResult Edit(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } var poll = _pollService.GetPollById(model.Id); if (poll == null) { throw new ArgumentException("No poll found with the specified id"); } if (ModelState.IsValid) { poll = model.ToEntity(poll); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.UpdatePoll(poll); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Updated")); return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); return(View(model)); }
public IActionResult Edit(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } var poll = _pollService.GetPollById(model.Id); if (poll == null) { //No poll found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { poll = model.ToEntity(poll); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; poll.Stores = model.SelectedStoreIds != null?model.SelectedStoreIds.ToList() : new List <string>(); poll.Locales = UpdateLocales(poll, model); poll.CustomerRoles = model.SelectedCustomerRoleIds != null?model.SelectedCustomerRoleIds.ToList() : new List <string>(); _pollService.UpdatePoll(poll); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Updated")); if (continueEditing) { //selected tab SaveSelectedTabIndex(); return(RedirectToAction("Edit", new { id = poll.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); //Store PrepareStoresMappingModel(model, poll, false); //locales AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = poll.GetLocalized(x => x.Name, languageId, false, false); }); //ACL PrepareAclModel(model, poll, false); return(View(model)); }
public async Task <IActionResult> Edit(PollModel model, bool continueEditing) { var poll = await _pollService.GetPollById(model.Id); if (poll == null) { //No poll found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { poll = model.ToEntity(poll, _dateTimeHelper); await _pollService.UpdatePoll(poll); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Updated")); if (continueEditing) { //selected tab await SaveSelectedTabIndex(); return(RedirectToAction("Edit", new { id = poll.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); //Store await model.PrepareStoresMappingModel(poll, _storeService, true); //ACL await model.PrepareACLModel(poll, true, _customerService); //locales await AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = poll.GetLocalized(x => x.Name, languageId, false, false); }); return(View(model)); }
public virtual IActionResult Edit(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } //try to get a poll with the specified id var poll = _pollService.GetPollById(model.Id); if (poll == null) { return(RedirectToAction("List")); } if (ModelState.IsValid) { poll = model.ToEntity(poll); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.UpdatePoll(poll); //save store mappings SaveStoreMappings(poll, model); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Updated")); if (!continueEditing) { return(RedirectToAction("List")); } //selected tab SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = poll.Id })); } //prepare model model = _pollModelFactory.PreparePollModel(model, poll, true); //if we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Create(PollModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var poll = model.ToEntity(); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.InsertPoll(poll); NotifySuccess(_localizationService.GetResource("Admin.ContentManagement.Polls.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); return(View(model)); }
public IActionResult Create(PollModel model, bool continueEditing) { if (ModelState.IsValid) { var poll = model.ToEntity(); _pollService.InsertPoll(poll); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); //Stores model.PrepareStoresMappingModel(null, true, _storeService); //locales AddLocales(_languageService, model.Locales); //ACL model.PrepareACLModel(null, true, _customerService); return(View(model)); }
public virtual async Task <IActionResult> Edit(PollModel model, bool continueEditing) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePolls)) { return(AccessDeniedView()); } //try to get a poll with the specified id var poll = await _pollService.GetPollByIdAsync(model.Id); if (poll == null) { return(RedirectToAction("List")); } if (ModelState.IsValid) { poll = model.ToEntity(poll); await _pollService.UpdatePollAsync(poll); //save store mappings await SaveStoreMappingsAsync(poll, model); _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.ContentManagement.Polls.Updated")); if (!continueEditing) { return(RedirectToAction("List")); } return(RedirectToAction("Edit", new { id = poll.Id })); } //prepare model model = await _pollModelFactory.PreparePollModelAsync(model, poll, true); //if we got this far, something failed, redisplay form return(View(model)); }
public virtual IActionResult Edit(PollModel model, bool continueEditing) { //try to get a poll with the specified id Poll poll = _pollService.GetPollById(model.Id); if (poll == null) { return(RedirectToAction("List")); } if (ModelState.IsValid) { poll = model.ToEntity(poll); poll.StartDateUtc = model.StartDate; poll.EndDateUtc = model.EndDate; _pollService.UpdatePoll(poll); SuccessNotification("Anket Güncellendi"); if (!continueEditing) { return(RedirectToAction("List")); } //selected tab SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = poll.Id })); } //prepare model model = _pollModelFactory.PreparePollModel(model, poll, true); //if we got this far, something failed, redisplay form return(View(model)); }