public IActionResult Edit(TopicModel model, bool continueEditing) { var topic = _topicService.GetTopicById(model.Id); if (topic == null) { //No topic found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { topic = _topicViewModelService.UpdateTopicModel(topic, model); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Topics.Updated")); if (continueEditing) { //selected tab SaveSelectedTabIndex(); return(RedirectToAction("Edit", new { id = topic.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form model.Url = Url.RouteUrl("Topic", new { SeName = topic.GetSeName() }, "http"); //templates _topicViewModelService.PrepareTemplatesModel(model); //Store model.PrepareStoresMappingModel(topic, true, _storeService); //ACL model.PrepareACLModel(topic, true, _customerService); return(View(model)); }
public async Task <IActionResult> Edit(TopicModel model, bool continueEditing) { if (model.StartDateUtc.HasValue && model.EndDateUtc.HasValue && model.StartDateUtc >= model.EndDateUtc) { ModelState.AddModelError(nameof(model.StartDateUtc), "Start Date cannot be later than End Date"); } var topic = await _topicService.GetTopicById(model.Id); if (topic == null) { //No topic found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { topic = await _topicViewModelService.UpdateTopicModel(topic, model); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Topics.Updated")); if (continueEditing) { //selected tab await SaveSelectedTabIndex(); return(RedirectToAction("Edit", new { id = topic.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form model.Url = Url.RouteUrl("Topic", new { SeName = topic.GetSeName(_workContext.WorkingLanguage.Id) }, "http"); //templates await _topicViewModelService.PrepareTemplatesModel(model); //Store await model.PrepareStoresMappingModel(topic, _storeService, true); //ACL await model.PrepareACLModel(topic, true, _customerService); return(View(model)); }