public string savehf(IFormCollection collection) { yjfk yjfk = new yjfk(); try { if (ModelState.IsValid) { var model = HttpContext.Session.Get("CurrentUser"); //获取session if (model == null) { return("nologin"); } else { string hex = System.Text.Encoding.Default.GetString(model); //获取json数据 ry sta = JsonConvert.DeserializeObject <ry>(hex); //转换成model数据 var updateResult = TryUpdateModelAsync <yjfk>(yjfk); yjfk.ry_id = sta.id; yjfk.status = 0; yjfk.hf_time = DateTime.Now; yjfkRepository.AddData(yjfk); return("success"); } } return("fail"); } catch (Exception ex) { return("fail"); } }
/// <summary> /// 提交反馈 /// </summary> /// <param name="wenti">提问的问题</param> /// <param name="lxfs">联系方式</param> /// <param name="tplist">反馈的图片</param> /// <returns>返回调用结果</returns> /// <para name="code">200=成功 其他请参看代码表</para> /// <para name="msg">提示信息</para> /// <para name="data"></para> /// <remarks> /// 2016-03-12 林建生 /// </remarks> public static object addyjfk(string wenti = "", string lxfs = "", string tplist = "") { if (wenti.Length > 5 || !string.IsNullOrEmpty(tplist)) { EFDB db = new EFDB(); Guid gid = Guid.NewGuid(); var b = new yjfk { gid = gid, wenti = wenti, zt = 2, beizhu = ApiHelper.sjxh + "," + ((sjxt)Enum.Parse(typeof(LJSheng.Data.Helps.sjxt), ApiHelper.sjxt.ToString(), true)).ToString() + "," + ApiHelper.bbh, lxfs = lxfs, rukusj = DateTime.Now }; db.yjfk.Add(b); if (db.SaveChanges() == 1) { //插入反馈的图片 if (!String.IsNullOrEmpty(tplist)) { string[] list = tplist.Split('#'); foreach (string s in list) { Guid yjgid = Guid.NewGuid(); var tp = new yjtp { gid = yjgid, yjgid = gid, tupian = s, rukusj = DateTime.Now }; db.yjtp.Add(tp); db.SaveChanges(); } } return(new ApiResult("提交成功", new { })); } else { return(new ApiResult("提交失败")); } } else { return(new ApiResult("请详细描述问题!")); } }