public ActionResult Edit(HomeMenu obj) { try { var munuName = _homeMenuRepository.GetAll().FirstOrDefault(x => x.Name.Trim() == obj.Name.Trim() && x.ID != obj.ID); if (munuName != null) { return(Json(new { IsSuccess = false, Messenger = "Tên menu đã tồn tại", }, JsonRequestBehavior.AllowGet)); } obj.LinkSeo = HelperString.RenderLinkSeo(obj.Name); _homeMenuRepository.Edit(obj); return(Json(new { IsSuccess = true, Messenger = "Cập nhật menu thành công", }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { IsSuccess = false, Messenger = string.Format("Cập nhật menu thất bại") }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(HomeMenu obj) { try { var menu = _homeMenuRepository.GetAll().FirstOrDefault(x => x.Name.Trim() == obj.Name.Trim()); if (menu != null) { return(Json(new { IsSuccess = false, Messenger = "Tên menu đã tồn tại", }, JsonRequestBehavior.AllowGet)); } obj.LinkSeo = HelperString.RenderLinkSeo(obj.Name); obj.CreatedDate = DateTime.Now; _homeMenuRepository.Add(obj); return(Json(new { IsSuccess = true, Messenger = "Thêm mới menu thành công", }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Messenger = string.Format("Thêm mới menu thất bại") }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(Product product, string isContinue) { try { var obj = productRepository.GetAll().FirstOrDefault(x => x.Name == product.Name); if (obj != null) { return(Json(new { IsSuccess = false, Messenger = "Tên sản phẩm đã tồn tại" }, JsonRequestBehavior.AllowGet)); } product.CreatedDate = DateTime.Now; product.LinkSeo = HelperString.RenderLinkSeo(product.Name); productRepository.Add(product); return(Json(new { IsContinue = isContinue, IsSuccess = true, Messenger = "Thêm mới thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Messenger = "Thêm mới thất bại" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(Product product) { try { var obj = productRepository.GetAll().FirstOrDefault(x => x.Name == product.Name && x.ID != product.ID); if (obj != null) { return(Json(new { IsSuccess = false, Messenger = "Tên sản phẩm đã tồn tại" }, JsonRequestBehavior.AllowGet)); } product.LinkSeo = HelperString.RenderLinkSeo(product.Name); productRepository.Edit(product); return(Json(new { IsSuccess = true, Messenger = "Cập nhật thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { IsSuccess = false, Messenger = "Cập nhật thất bại" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(Policy model) { try { if (string.IsNullOrEmpty(model.Contents)) { return(Json(new { IsSuccess = false, Message = "Vui lòng thêm nội dung" }, JsonRequestBehavior.AllowGet)); } model.LinkSeo = HelperString.RenderLinkSeo(model.MetaTitle); policyRepository.Edit(model); return(Json(new { IsSuccess = true, Message = "Cập nhật thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Message = "Cập nhật thất bại" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(Category model) { try { var obj = categoryRepository.GetAll().FirstOrDefault(x => x.Name.Trim() == model.Name.Trim() && x.ID != model.ID); if (obj != null) { return(Json(new { IsSuccess = false, Messenger = "Tên danh mục đã tồn tại" }, JsonRequestBehavior.AllowGet)); } model.LinkSeo = HelperString.RenderLinkSeo(model.Name); categoryRepository.Edit(model); return(Json(new { IsSuccess = true, Messenger = "Cập nhật thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Messenger = "Cập nhật thất bại" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(About model) { try { if (string.IsNullOrEmpty(model.Contents)) { return(Json(new { IsSuccess = false, Message = "Vui lòng thêm nội dung" }, JsonRequestBehavior.AllowGet)); } model.Createddate = DateTime.Now; model.LinkSeo = HelperString.RenderLinkSeo(model.MetaTitle); aboutRepository.Add(model); return(Json(new { IsSuccess = true, Message = "Thêm mới thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Message = "Thêm mới thất bại" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(Instruction model) { try { var obj = _instructionRepository.GetAll().FirstOrDefault(x => x.Title.Trim().Equals(model.Title.Trim())); if (obj != null) { return(Json(new { IsSuccess = false, Messenger = string.Format("Tiêu đề đã tồn tại") }, JsonRequestBehavior.AllowGet)); } model.LinkSeo = HelperString.RenderLinkSeo(model.Title); model.CreatedDate = DateTime.Now; if (_instructionRepository.Add(model)) { return(Json(new { IsSuccess = true, Messenger = "Thêm mới thành công", }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, Messenger = string.Format("Thêm mới thất bại") }, JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(new { IsSuccess = false, Messenger = string.Format("Thêm mới thất bại") }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(News model, string close) { try { var news = newsRepository.GetAll().FirstOrDefault(x => x.MetaTitle.Trim().Equals(model.MetaTitle.Trim())); if (news != null) { return(Json(new { IsSuccess = true, Message = "Tiêu đề tin tức đã tồn tại", }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(model.Contents)) { return(Json(new { IsSuccess = false, Message = "Vui lòng thêm nội dung bài viết", }, JsonRequestBehavior.AllowGet)); } model.LinkSeo = HelperString.RenderLinkSeo(model.MetaTitle); model.CreatedBy = User.ID; model.CreatedDate = DateTime.Now; newsRepository.Add(model); return(Json(new { Close = close, IsSuccess = true, Message = "Thêm mới thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { IsSuccess = false, Message = "Thêm mới thất bại " }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(Instruction model) { try { var objInst = _instructionRepository.GetAll().FirstOrDefault(x => x.Title.Trim().Equals(model.Title.Trim()) && x.ID != model.ID); if (objInst != null) { return(Json(new { IsSuccess = false, Messenger = string.Format("Tiêu đề đã tồn tại") }, JsonRequestBehavior.AllowGet)); } model.LinkSeo = HelperString.RenderLinkSeo(model.Title); if (_instructionRepository.Edit(model)) { return(Json(new { IsSuccess = true, Messenger = "Cập nhật thành công", }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, Messenger = string.Format("Cập nhật thất bại") }, JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(new { IsSuccess = false, Messenger = string.Format("Cập nhật thất bại") }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(News model) { try { var news = newsRepository.GetAll().FirstOrDefault(x => x.MetaTitle.Trim().Equals(model.MetaTitle.Trim())); if (news != null && news.ID != model.ID) { return(Json(new { IsSuccess = false, Message = "Tiêu đề tin tức đã tồn tại", }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(model.Contents)) { return(Json(new { IsSuccess = true, Message = "Vui lòng thêm nội dung bài viết", }, JsonRequestBehavior.AllowGet)); } var page = Session["PAGE"]; if (page == null) { page = 1; } model.LinkSeo = HelperString.RenderLinkSeo(model.MetaTitle); newsRepository.Edit(model); return(Json(new { Page = (int)page, IsSuccess = true, Message = "Cập nhật thành công", JsonRequestBehavior.AllowGet })); } catch (Exception e) { return(Json(new { IsSuccess = false, Message = "Cập nhật thất bại", JsonRequestBehavior.AllowGet })); } }