public ActionResult Edit(StaticContentType contentType) { CheckIfSiteAdmin(); var staticContentViewModel = new StaticContentViewModel(); var staticContent = _staticContentService.GetStaticContent(contentType); staticContentViewModel.Content = staticContent.Content; try { // Format the HTML returned by Telerik control so that indented HTML will be shown in HTML editor. staticContentViewModel.Content = XElement.Parse(staticContentViewModel.Content).ToString(); } catch (XmlException) { try { // In case if the HTML doesn't have a root, add a <p> tag as wrapper. staticContentViewModel.Content = XElement.Parse(string.Format(CultureInfo.CurrentCulture, "<p>{0}</p>", staticContentViewModel.Content)).ToString(); } catch (XmlException) { // Consume any other Xml exception with parsing and try to load the string as is. // There could be problem like the text is not a valid XML. } } return(View("Save", staticContentViewModel)); }
public ActionResult Edit(StaticContentType staticContentType) { if (ModelState.IsValid) { _repo.Update(staticContentType); return(RedirectToAction("Index")); } return(View(staticContentType)); }
/// <summary> /// Gets static content from the DB /// </summary> /// <param name="staticContentType">static Content Type</param> /// <returns>static content object</returns> public StaticContentDetails GetStaticContent(StaticContentType staticContentType) { Expression <Func <StaticContent, bool> > condition = (staticContent) => staticContent.StaticContentType.TypeID == (int)staticContentType && staticContent.IsDeleted == false; var content = _staticContentRepository.GetItem(condition); var staticContentDetails = new StaticContentDetails(); Mapper.Map(content, staticContentDetails); return(staticContentDetails); }
public void Render(StaticContentType staticContentType) { try { var staticContent = _staticContentService.GetStaticContent(staticContentType); PartialView("StaticContentView", staticContent).ExecuteResult(ControllerContext); } catch (Exception) { // Consume the exception and render rest of the views in the page. // TODO: Log the exception? } }
// GET: Admin/StaticContentTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaticContentType staticContentType = _repo.Get(id.Value); if (staticContentType == null) { return(HttpNotFound()); } return(PartialView(staticContentType)); }
public void Update(StaticContentType obj, out OperationResult operationResult) { lock (Lock) { if (obj == null) { operationResult = new OperationResult { Type = OperationResult.ResultType.Warning }; return; } Common.Instance.Update (obj, objs => objs.StaticContentTypeId == obj.StaticContentTypeId && objs.LanguageId == obj.LanguageId, out operationResult); } }
public void Insert(StaticContentType obj, out OperationResult operationResult) { lock (Lock) { if (obj == null) { operationResult = new OperationResult { Type = OperationResult.ResultType.Warning }; } else { Common.Instance.Insert(obj, out operationResult); } } }
public async Task <IActionResult> Update(int id, StaticContentType model) { model.Id = id; var result = await _repo.Update(model); if (result == null) { return(StatusCode(StatusCodes.Status500InternalServerError, new Response <StaticContentType>() { Succeeded = false, Message = "ثبت محتوا با مشکل مواجه شد لطفا ورودی های خود را چک کرده و مجددا تلاش کنید" })); } return(Ok(new Response <StaticContentType>(result) { Message = "محتوا با موفقیت بروزرسانی شد" })); }