public JsonResult AddOrEditPost(Blogview model) { if (model == null) { return(MyJson(new JsonResponse("", 1, "参数不合法"))); } var modelwhere = CommonHelper.ModelToDic <Blogview>(model); if (string.IsNullOrEmpty(model.KID)) { modelwhere.Add(nameof(Bloginfo.Type), 1); modelwhere.Add(nameof(Bloginfo.CreateUserId), EmployeeInfo.Model?.KID); modelwhere.Add(nameof(Bloginfo.CreateUserName), EmployeeInfo.Model?.UserName); modelwhere.Add(nameof(Bloginfo.CreateTime), DateTime.Now); Result blog = BlogHelper.Add_Bloginfo(modelwhere, new Service.Models.View.OpertionUser()); return(MyJson(new JsonResponse("", blog.IsSucceed ? 0 : 1, blog.IsSucceed ? "添加成功" : "失败"))); } else { if (modelwhere.ContainsKey(nameof(Bloginfo.KID))) { modelwhere.Remove(nameof(Bloginfo.KID)); } modelwhere.Add(nameof(Bloginfo.UpdateUserId), EmployeeInfo.Model?.KID); modelwhere.Add(nameof(Bloginfo.UpdateUserName), EmployeeInfo.Model?.UserName); modelwhere.Add(nameof(Bloginfo.UpdateTime), DateTime.Now); Result blog = BlogHelper.Update_Bloginfo(modelwhere, model.KID.Toint(), new Service.Models.View.OpertionUser()); return(MyJson(new JsonResponse("", blog.IsSucceed ? 0 : 1, blog.IsSucceed ? "修改成功" : "修改失败"))); } }
public JsonResponse AddItemBlog([FromBody] JsonRequest model) { try { UpdateView up = model?.Data?.ToString().DeserializeObject <UpdateView>(); if (up == null || up.Update == null) { return(new JsonResponse { Code = 1, Msg = "参数不合法" }); } var opt = new OpertionUser(); var content = up.Update[nameof(Blogcontent.Content)].ToString(); var blognum = Guid.NewGuid().ToString().Replace("-", ""); var infodic = AddBaseInfo <Bloginfo>(up.Update, model.Token, true, ref opt); infodic.Add(nameof(Bloginfo.BlogNum), blognum); //var contdic = AddBaseInfo<Blogcontent>(updic, model.Token, true, ref opt); infodic.Add(nameof(Blogcontent.BloginfoNum), blognum); var res1 = BlogHelper.Add_Bloginfo(infodic, opt); //var res2 = BlogHelper.Add_Blogcontent(infodic, opt); if (!res1.IsSucceed) { return(new JsonResponse { Code = 1, Msg = $"添加失败{res1.SerializeObject()};" }); } Task.Run(() => { CacheHelper.DelCacheItem(ConfigUtil.BlogListCacheKey); CacheHelper.DelCacheItem($"{ConfigUtil.BlogItemCacheKeyPrefix}{up.Num}"); }); return(FastResponse("", model.Token, 0, 0, "添加成功")); } catch (Exception ex) { LogHelper.WriteLog(ex, "AdminBlogController/AddItemBlog"); return(new JsonResponse { Code = 1, Msg = "程序视乎开小差" + ex.Message }); } }