/// <summary> /// 新闻详情页 /// Add by ZhengSong /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult NewDetailed(int id) { if (_newService.Get(id) == null) { throw new Exception("输入参数有误!"); } NewListModel model = new NewListModel(); model.ShowCategoryListModel = ShowCategoryListModel(); model.ArticleModel = _newService.Get(id).ToModel <ArticleModel>(); return(View(model)); }
/// <summary> /// 新闻中心 /// Add by zhengsong /// Update By xiaofan /// </summary> /// <returns></returns> public ActionResult NewList(int categoryId) { if (_newService.GetArticleListByCategoryId(categoryId) == null) { throw new Exception("输入的参数有误"); } NewListModel model = new NewListModel(); model.ShowCategoryListModel = ShowCategoryListModel(); //获取当前类别列表信息 model.CategoryInfo = _newService.GetCategory(categoryId).ToModel <CategoryModel>(); model.GetArticleList = _newService.GetArticleListByCategoryId(categoryId).ToModelAsCollection <Article, ArticleModel>(); model.GetId = categoryId; return(View(model)); }
public IActionResult Create([FromBody] NewListModel model) { var username = User?.Identity?.Name; var userResult = _userService?.GetUserForUsername(username); if (userResult?.Type == ResultType.Success) { var user = userResult.ReturnObj; var createResult = _shoppingListService?.CreateNewShoppinglist(model?.ListName, user); if (createResult?.Type == ResultType.Success) { var list = createResult.ReturnObj; return(Ok($"List with name {list.Listname} was successfully added")); } return(BadRequest(createResult?.Message)); } return(BadRequest(userResult?.Message)); }