/// <summary> /// 更新恋爱观资料表 /// </summary> /// <param name="id"></param> /// <param name="love"></param> public void UpdateLoveView(int id, LoveView love) { using (var db = new LoveDb()) { var dst = db.LoveViews.SingleOrDefault(n => n.UserId == id); if (dst == null) { return; } var i = 0; dst.WorkTimePlan = Modifycount(love.WorkTimePlan, ref i); dst.Smoking = Modifycount(love.Smoking, ref i); dst.Drinking = Modifycount(love.Drinking, ref i); dst.LoveDuration = Modifycount(love.LoveDuration, ref i); dst.WantaBaby = Modifycount(love.WantaBaby, ref i); dst.ParentLiveTogether = Modifycount(love.ParentLiveTogether, ref i); dst.Housework = Modifycount(love.Housework, ref i); dst.ManageMoney = Modifycount(love.ManageMoney, ref i); dst.Cooking = Modifycount(love.Cooking, ref i); dst.Allopatry = Modifycount(love.Allopatry, ref i); var statistic = db.InfoStatistics.SingleOrDefault(b => b.UserId == id); if (statistic != null) { statistic.LoveViewsReal = i; var real = statistic.DetialsInfoReal + statistic.BaseInfoReal + statistic.LoveViewsReal; var imgsum = db.Iamgboxes.Count(n => n.UserId == id); imgsum = imgsum > 22 ? 22 : imgsum; real += imgsum; //还差一条标准 .. 回答问题 或者别的。 准备18道题目。 var x = (float)real / 50; statistic.Percent = x; // (float)Math.Round(x, 2); } db.SaveChanges(); } }
/// <summary> /// 修改恋爱观 /// </summary> /// <param name="info"></param> /// <returns></returns> public ActionResult UpdateLoveView(LoveView info) { LoveDb.UpdateLoveView(CheckValid(), info); return Json(info); }