public async Task <IActionResult> CategoryCreate(BlogCategoryModel model, bool continueEditing) { if (ModelState.IsValid) { if (_workContext.CurrentCustomer.IsStaff()) { model.LimitedToStores = true; model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId }; } var blogCategory = model.ToEntity(); await _blogService.InsertBlogCategory(blogCategory); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Blog.BlogCategory.Added")); return(continueEditing ? RedirectToAction("CategoryEdit", new { id = blogCategory.Id }) : RedirectToAction("CategoryList")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = await _languageService.GetAllLanguages(true); //locales await AddLocales(_languageService, model.Locales); //Stores await model.PrepareStoresMappingModel(null, _storeService, true); return(View(model)); }
public async Task <IActionResult> CategoryCreate(BlogCategoryModel model, bool continueEditing) { if (ModelState.IsValid) { if (await _groupService.IsStaff(_workContext.CurrentCustomer)) { model.Stores = new string[] { _workContext.CurrentCustomer.StaffStoreId }; } var blogCategory = model.ToEntity(); blogCategory.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName, _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls, _seoSettings.SeoCharConversion); await _blogService.InsertBlogCategory(blogCategory); Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Added")); return(continueEditing ? RedirectToAction("CategoryEdit", new { id = blogCategory.Id }) : RedirectToAction("CategoryList")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = await _languageService.GetAllLanguages(true); //locales await AddLocales(_languageService, model.Locales); return(View(model)); }
public HttpResponseMessage GetBlogCategory(int siteId, int categoryId) { ContentClientProcessor.UserContext.SiteId = siteId; BlogCategoryModel blogCategory = ContentClientProcessor.GetBlogCategory(categoryId); return(Request.CreateResponse(HttpStatusCode.OK, blogCategory)); }
public IHttpActionResult Save(BlogCategoryModel item) { try { if (item != null) { BlogCategoryService.SaveOrUpdate(item); return(Ok(item)); } return(BadRequest("No se ha enviado información que almacenar.")); } catch (HibernateAdoException hibernateException) { if (hibernateException.InnerException is GenericADOException) { if (hibernateException.InnerException.InnerException is OracleException) { return(InternalServerError(hibernateException.InnerException.InnerException)); } return(InternalServerError(hibernateException.InnerException)); } return(InternalServerError(hibernateException)); } catch (Exception exception) { return(InternalServerError(exception)); } }
public HttpResponseMessage GetBlogs(int siteId, int categoryId) { ContentClientProcessor.UserContext.SiteId = siteId; SetPagingParameters(ContentClientProcessor.RequestContext); BlogCategoryModel blogCategory = ContentClientProcessor.GetBlogs(categoryId); return(GetListResult <BlogCategoryModel>(blogCategory, ContentClientProcessor.RequestContext, ContentClientProcessor.ResponseContext)); }
public ActionResult DeleteConfirmed(int id) { BlogCategoryModel blogCategoryModel = db.BlogCategories.Find(id); db.BlogCategories.Remove(blogCategoryModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> CategoryEdit(BlogCategoryModel model, bool continueEditing) { var blogCategory = await _blogService.GetBlogCategoryById(model.Id); if (blogCategory == null) { //No blog post found with the specified id return(RedirectToAction("CategoryList")); } if (_workContext.CurrentCustomer.IsStaff()) { if (!blogCategory.AccessToEntityByStore(_workContext.CurrentCustomer.StaffStoreId)) { return(RedirectToAction("CategoryEdit", new { id = blogCategory.Id })); } } if (ModelState.IsValid) { if (_workContext.CurrentCustomer.IsStaff()) { model.LimitedToStores = true; model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId }; } blogCategory = model.ToEntity(blogCategory); blogCategory.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName, _seoSettings); await _blogService.UpdateBlogCategory(blogCategory); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Blog.BlogCategory.Updated")); if (continueEditing) { //selected tab await SaveSelectedTabIndex(); return(RedirectToAction("CategoryEdit", new { id = blogCategory.Id })); } return(RedirectToAction("CategoryList")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = await _languageService.GetAllLanguages(true); //locales await AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = blogCategory.GetLocalized(x => x.Name, languageId, false, false); }); //Store await model.PrepareStoresMappingModel(blogCategory, _storeService, true, _workContext.CurrentCustomer.StaffStoreId); return(View(model)); }
public async Task <IActionResult> CategoryCreate() { ViewBag.AllLanguages = await _languageService.GetAllLanguages(true); var model = new BlogCategoryModel(); //locales await AddLocales(_languageService, model.Locales); return(View(model)); }
public IActionResult CategoryCreate() { ViewBag.AllLanguages = _languageService.GetAllLanguages(true); var model = new BlogCategoryModel(); //locales AddLocales(_languageService, model.Locales); //Stores model.PrepareStoresMappingModel(null, false, _storeService); return(View(model)); }
public ActionResult Edit([Bind(Include = "BlogId,CategoryId")] BlogCategoryModel blogCategoryModel) { if (ModelState.IsValid) { db.Entry(blogCategoryModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BlogId = new SelectList(db.Blogs, "BlogId", "Title", blogCategoryModel.BlogId); ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", blogCategoryModel.CategoryId); return(View(blogCategoryModel)); }
public Task <IViewComponentResult> InvokeAsync() { var blog = (Blog)_siteRequest.Current.ResolvedData["blog"]; var posts = (PaginationData <Post>)_siteRequest.Current.ResolvedData["posts"]; var blogCateModel = new BlogCategoryModel { Blog = blog, Posts = posts }; return(Task.FromResult <IViewComponentResult>(View(blogCateModel))); }
/// <summary> /// 修改博文分类 /// </summary> /// public void UpdateBlogCategoryModelContent(BlogCategoryModel model) { IRepository <BlogStoryCategory> storyCategoryRep = Factory.Factory <IRepository <BlogStoryCategory> > .GetConcrete <BlogStoryCategory>(); BlogStoryCategory mymodel = storyCategoryRep.GetByKey(model.BlogCategoryID); mymodel.CategoryName = model.CategoryName; mymodel.Description = model.Description; mymodel.IconName = model.IconName; mymodel.OrderPriority = model.OrderPriority; storyCategoryRep.Update(mymodel); storyCategoryRep.PersistAll(); }
public IHttpActionResult PostBlogCategory(BlogCategoryModel data) { try { var result = oSvc.PostBlogCategory(data); return(Ok(result)); } catch (Exception ex) { ExceptionModel exc = oException.Set(ex); return(Ok(exc)); } }
public async Task <IActionResult> CategoryEdit(BlogCategoryModel model, bool continueEditing) { var blogCategory = await _blogService.GetBlogCategoryById(model.Id); if (blogCategory == null) { //No blog post found with the specified id return(RedirectToAction("CategoryList")); } if (await _groupService.IsStaff(_workContext.CurrentCustomer)) { if (!blogCategory.AccessToEntityByStore(_workContext.CurrentCustomer.StaffStoreId)) { return(RedirectToAction("CategoryEdit", new { id = blogCategory.Id })); } } if (ModelState.IsValid) { if (await _groupService.IsStaff(_workContext.CurrentCustomer)) { model.Stores = new string[] { _workContext.CurrentCustomer.StaffStoreId }; } blogCategory = model.ToEntity(blogCategory); blogCategory.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(blogCategory.SeName) ? blogCategory.Name : blogCategory.SeName, _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls, _seoSettings.SeoCharConversion); await _blogService.UpdateBlogCategory(blogCategory); Success(_translationService.GetResource("Admin.Content.Blog.BlogCategory.Updated")); if (continueEditing) { //selected tab await SaveSelectedTabIndex(); return(RedirectToAction("CategoryEdit", new { id = blogCategory.Id })); } return(RedirectToAction("CategoryList")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = await _languageService.GetAllLanguages(true); //locales await AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = blogCategory.GetTranslation(x => x.Name, languageId, false); }); return(View(model)); }
/// <summary> /// SaveBlogCategory /// </summary> /// <param name="blogCategory"></param> public void SaveBlogCategory(BlogCategoryModel blogCategory) { BlogCategoryDC blogCategoryDC = Mapper.Map <BlogCategoryModel, BlogCategoryDC>(blogCategory); ServiceResponse <int> saveBlogCategoryResponse = _contentProxy.Execute(opt => opt.SaveBlogCategory(blogCategoryDC)); if (saveBlogCategoryResponse.Status != ResponseStatus.Success) { HandleError(saveBlogCategoryResponse.Status, saveBlogCategoryResponse.ResponseMessage); } else { blogCategory.BlogCategoryId = saveBlogCategoryResponse.Result; } }
// GET: BlogCategories/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BlogCategoryModel blogCategoryModel = db.BlogCategories.Find(id); if (blogCategoryModel == null) { return(HttpNotFound()); } return(View(blogCategoryModel)); }
public async Task <IActionResult> CategoryCreate() { ViewBag.AllLanguages = await _languageService.GetAllLanguages(true); var model = new BlogCategoryModel(); //locales await AddLocales(_languageService, model.Locales); //Stores await model.PrepareStoresMappingModel(null, _storeService, false, _workContext.CurrentCustomer.StaffStoreId); return(View(model)); }
/// <summary> /// GetBlogCategory /// </summary> /// <param name="blogCategoryId"></param> /// <returns></returns> public BlogCategoryModel GetBlogCategory(int blogCategoryId) { BlogCategoryModel BlogCategoryResult = new BlogCategoryModel(); ServiceResponse <BlogCategoryDC> BlogCategoryResponse = _contentProxy.Execute(opt => opt.GetBlogCategory(blogCategoryId)); if (BlogCategoryResponse.Status == ResponseStatus.Success) { BlogCategoryResult = Mapper.Map <BlogCategoryDC, BlogCategoryModel>(BlogCategoryResponse.Result); } else { HandleError(BlogCategoryResponse.Status, BlogCategoryResponse.ResponseMessage); } return(BlogCategoryResult); }
public int SaveOrUpdate(BlogCategoryModel entity) { if (entity.ID != 0) { var dbEntity = BlogCategoryRepository.Get(entity.ID); if (dbEntity != null) { BlogCategoryRepository.Update(dbEntity); return(dbEntity.ID); } throw new ArgumentException("Invalid id"); } return(BlogCategoryRepository.Save(entity)); }
// GET: BlogCategories/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BlogCategoryModel blogCategoryModel = db.BlogCategories.Find(id); if (blogCategoryModel == null) { return(HttpNotFound()); } ViewBag.BlogId = new SelectList(db.Blogs, "BlogId", "Title", blogCategoryModel.BlogId); ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", blogCategoryModel.CategoryId); return(View(blogCategoryModel)); }
/// <summary> /// 获取一个博文分类 /// </summary> /// <param name="name">名称</param> /// <returns></returns> public BlogCategoryModel GetBlogCategoryModelContentByName(string name) { IRepository <BlogStoryCategory> storyCategoryRep = Factory.Factory <IRepository <BlogStoryCategory> > .GetConcrete <BlogStoryCategory>(); BlogStoryCategory blogstory = storyCategoryRep.Find(new Specification <BlogStoryCategory>(a => a.CategoryName == name)); BlogCategoryModel k = new BlogCategoryModel(); if (blogstory != null) { k = new BlogCategoryModel() { BlogCategoryID = blogstory.Id, CategoryName = blogstory.CategoryName, IconName = blogstory.IconName, Description = blogstory.Description, OrderPriority = blogstory.OrderPriority }; } return(k); }
public async Task GetServiceBlog(int pageIndex, int pageSize, int position) { string url = string.Empty; //开放平台上请求数据 if (position < 2) { if (position == 0) { url = string.Format(Constant.BLOG_HOME_LIST, pageIndex, pageSize); } else { url = string.Format(Constant.BLOG_PICKED_LIST, pageIndex, pageSize); } await HttpClientUtil.GetAsync <List <BlogModel> >(url, null, async (list) => { blogView.GetServiceBlogSuccess(list); BlogCategoryModel model = MyApplication.blogCategoryList.Where(f => f.Position == position).FirstOrDefault(); list.ForEach(f => f.CategoryId = model.CategoryId); await SqliteDatabase.Instance().UpdateBlogList(list); }, (error) => { blogView.GetServiceBlogFail(error); }); } //从网页总抓取数据 else { url = string.Format(Constant.BLOG_CATEGORY_LIST, pageIndex, pageSize); BlogCategoryModel model = MyApplication.blogCategoryList.Where(f => f.Position == position).FirstOrDefault(); model.PageIndex = pageIndex; await HttpClientUtil.PostBlogCategoryAsync(url, model, async (list) => { blogView.GetServiceBlogSuccess(list); list.ForEach(f => f.CategoryId = model.CategoryId); await SqliteDatabase.Instance().UpdateBlogList(list); }, (error) => { blogView.GetServiceBlogFail(error); }); } }
public IHttpActionResult PutBlogCategory(int?id, BlogCategoryModel data) { try { if (!id.HasValue) { return(BadRequest()); } var result = oSvc.PutBlogCategory(id.Value, data); return(Ok(result)); } catch (Exception ex) { ExceptionModel exc = oException.Set(ex); return(Ok(exc)); } }
public ActionResult BlogCategory(int Id = 0) { if (!SavePermissionsToViewBag(FeatureEnum.Blog)) { return(Redirect("~/home/unauthorized")); } BlogCategoryModel BlogCategoryModel = new BlogCategoryModel(); BlogCategoryModel.BlogCategoryId = Id; if (Request.IsAjaxRequest()) { return(PartialView(BlogCategoryModel)); } else { return(View(BlogCategoryModel)); } }
public IActionResult CategoryCreate(BlogCategoryModel model, bool continueEditing) { if (ModelState.IsValid) { var blogCategory = model.ToEntity(); _blogService.InsertBlogCategory(blogCategory); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Blog.BlogCategory.Added")); return(continueEditing ? RedirectToAction("CategoryEdit", new { id = blogCategory.Id }) : RedirectToAction("CategoryList")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = _languageService.GetAllLanguages(true); //locales AddLocales(_languageService, model.Locales); //Stores model.PrepareStoresMappingModel(null, true, _storeService); return(View(model)); }
public bool PutBlogCategory(int blogCategoryId, BlogCategoryModel data) { string xml = Helper.XmlSerializer <BlogCategoryModel>(data); using (var context = new SQLContext()) { SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@blogcategoryid", SqlDbType.Int); param[0].Value = blogCategoryId; param[1] = new SqlParameter("@data", SqlDbType.Xml); param[1].Value = xml; param[2] = new SqlParameter("@userid", SqlDbType.Int); param[2].Value = 0; context.Database.ExecuteSqlCommand( "[dbo].[s_put_blog_category] @blogcategoryid, @data, @userid", param); return(true); } }
/// <summary> /// GetBlogs /// </summary> /// <param name="blogCategoryId"></param> /// <returns></returns> public BlogCategoryModel GetBlogs(int blogCategoryId) { BlogCategoryModel blogCategoryModel = null; //BlogsRequest.RequestContextParameters = Mapper.Map<RequestContextParameter,RequestContextParameterDC>(this.RequestContext); ServiceResponse <BlogCategoryDC> BlogsResponse = _contentProxy.Execute(opt => opt.GetBlogs(blogCategoryId)); if (BlogsResponse.Status == ResponseStatus.Success) { blogCategoryModel = Mapper.Map <BlogCategoryDC, BlogCategoryModel>(BlogsResponse.Result); blogCategoryModel.Blogs = new List <BlogModel>(); BlogsResponse.Result.Blogs.ForEach( Blog => blogCategoryModel.Blogs.Add(Mapper.Map <BlogDC, BlogModel>(Blog)) ); this.ResponseContext.NumberOfRecords = BlogsResponse.ResponseParameters.NumberOfRecords; } else { HandleError(BlogsResponse.Status, BlogsResponse.ResponseMessage); } return(blogCategoryModel); }
public async Task <IActionResult> CategoryEdit(BlogCategoryModel model, bool continueEditing) { var blogCategory = await _blogService.GetBlogCategoryById(model.Id); if (blogCategory == null) { //No blog post found with the specified id return(RedirectToAction("CategoryList")); } if (ModelState.IsValid) { blogCategory = model.ToEntity(blogCategory); await _blogService.UpdateBlogCategory(blogCategory); SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Blog.BlogCategory.Updated")); if (continueEditing) { //selected tab await SaveSelectedTabIndex(); return(RedirectToAction("CategoryEdit", new { id = blogCategory.Id })); } return(RedirectToAction("CategoryList")); } //If we got this far, something failed, redisplay form ViewBag.AllLanguages = await _languageService.GetAllLanguages(true); //locales await AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = blogCategory.GetLocalized(x => x.Name, languageId, false, false); }); //Store await model.PrepareStoresMappingModel(blogCategory, _storeService, true); return(View(model)); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Form["categoryid"])) { CategoryService myservice = new CategoryService(); BlogCategoryModel model = myservice.GetBlogCategoryModelContentByID(new Guid(Request.Form["categoryid"])); model.CategoryName = Request.Form["categoryname"].ToString(); model.Description = Request.Form["decription"].ToString(); model.OrderPriority = System.UInt16.Parse(Request.Form["priority"].ToString()); myservice.UpdateBlogCategoryModelContent(model); Response.Write("<script>alert('修改成功')</script>"); } else { myid = Request.QueryString["id"].ToString(); CategoryService myservice = new CategoryService(); BlogCategoryModel model = myservice.GetBlogCategoryModelContentByID(new Guid(myid)); _categoryname = model.CategoryName; _decription = model.Description; _priority = model.OrderPriority.ToString(); } }
/// <summary> /// 获取博文分类列表 /// </summary> /// <returns>博文分类列表</returns> public IList <BlogCategoryModel> GetBlogCategoryList() { IRepository <BlogStoryCategory> storyRep = Factory.Factory <IRepository <BlogStoryCategory> > .GetConcrete <BlogStoryCategory>(); int categoryCount = storyRep.FindAll().Count; IList <BlogStoryCategory> storys = storyRep.FindAll(new Specification <BlogStoryCategory>(s => s.Id != Guid.Empty).Skip(0).Take(categoryCount).OrderBy(st => st.OrderPriority)); IList <BlogCategoryModel> targets = new List <BlogCategoryModel>(); foreach (BlogStoryCategory story in storys) { BlogCategoryModel tmp = new BlogCategoryModel() { BlogCategoryID = story.Id, CategoryName = story.CategoryName, Description = story.Description, IconName = story.IconName, OrderPriority = story.OrderPriority }; targets.Add(tmp); } return(targets); }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void Update(BlogCategoryModel entity) { CurrentSession.Update(entity); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Save(BlogCategoryModel entity) { return (int) CurrentSession.Save(entity); }
public int SaveOrUpdate(BlogCategoryModel entity) { if (entity.ID != 0) { var dbEntity = BlogCategoryRepository.Get(entity.ID); if (dbEntity != null) { BlogCategoryRepository.Update(dbEntity); return dbEntity.ID; } throw new ArgumentException("Invalid id"); } return BlogCategoryRepository.Save(entity); }
public void Update(BlogCategoryModel entity) { BlogCategoryRepository.Update(entity); }
public IHttpActionResult Save(BlogCategoryModel item) { try { if (item != null) { BlogCategoryService.SaveOrUpdate(item); return Ok(item); } return BadRequest("No se ha enviado información que almacenar."); } catch (HibernateAdoException hibernateException) { if (hibernateException.InnerException is GenericADOException) { if (hibernateException.InnerException.InnerException is OracleException) { return InternalServerError(hibernateException.InnerException.InnerException); } return InternalServerError(hibernateException.InnerException); } return InternalServerError(hibernateException); } catch (Exception exception) { return InternalServerError(exception); } }
public int Save(BlogCategoryModel entity) { return BlogCategoryRepository.Save(entity); }