public static Baogao GetFirstBaogaoByBabyID(int bid) { Baogao baogao = new Baogao(); var baogaos = unitOfWork.baogaoRepository.Get(filter: u => u.BabyId == bid, orderBy: q => q.OrderByDescending(u => u.BaogaoId)); if (baogaos.Count() > 0) { baogao = baogaos.First(); } return(baogao); }
public ActionResult BaogaoDetail(int id) { Baogao baogao = unitOfWork.baogaoRepository.GetByID(id); AdsBaby baby = unitOfWork.adsBabysRepository.GetByID(baogao.BabyId); // string babyName = unitOfWork.adsBabysRepository.GetByID(baogao.BabyId).BabyName; string str = baogao.BaogaoDementionScore; string[] sArray = str.Split(','); List <BaogaoDemention> demlist = new List <BaogaoDemention>(); string chartscategories = "["; string chartsdata = "["; foreach (string s in sArray) { // string dem=s.ToString(); BaogaoDemention dem = new BaogaoDemention(); dem.demName = s.Substring(0, s.IndexOf(":")); dem.demScore = int.Parse(s.Substring(s.IndexOf(":") + 1)); if (dem.demName == "感觉能力") { dem.demReference = 30; } if (dem.demName == "交往能力") { dem.demReference = 44; } if (dem.demName == "运动能力") { dem.demReference = 29; } if (dem.demName == "语言能力") { dem.demReference = 31; } if (dem.demName == "自理能力") { dem.demReference = 25; } demlist.Add(dem); chartscategories = chartscategories + "\"" + dem.demName + "\"" + ","; chartsdata = chartsdata + dem.demScore + ","; } chartscategories = chartscategories.TrimEnd(',') + "]"; chartsdata = chartsdata.TrimEnd(',') + "]"; ViewData["dem"] = demlist; ViewBag.categories = chartscategories; ViewBag.chartsdata = chartsdata; ViewBag.babyName = baby.BabyName; ViewBag.babysex = baby.BabySex; ViewBag.babyage = DateTime.Now.Year - Convert.ToDateTime(baby.BabyBirthday).Year; return(View(baogao)); }
public static List <BaogaoDemention> PlanCategory(int bid) { Baogao baogao = BaogaoServices.GetFirstBaogaoByBabyID(bid); List <BaogaoDemention> demlist = new List <BaogaoDemention>(); if (string.IsNullOrEmpty(baogao.BaogaoWeight)) { return(demlist); } else { string x = baogao.BaogaoWeight; // string x = "感觉能力:99,交往能力:56,运动能力:46,语言能力:76,自理能力:90"; string[] sArray = x.Split(','); int number = 0; foreach (string s in sArray) { number++; // string dem=s.ToString(); BaogaoDemention dem = new BaogaoDemention(); dem.demName = s.Substring(0, s.IndexOf(":")); // dem.demScore = int.Parse(s.Substring(s.IndexOf(":") + 1)); //Category category = (from c in db.Categorys // orderby c.CategorySort ascending // where c.CategoryName == dem.demName // select c).First(); Category category = unitOfWork.categorysRepository.Get(filter: u => u.CategoryName == dem.demName).First(); dem.demNumber = number; dem.demIcon = category.CategoryIcon; dem.demcategoryid = category.ID; demlist.Add(dem); } return(demlist); } }
public JsonResult SaveScaleResult(string score, string Dementionscore, string totalscore, string weight) { int customerId = int.Parse(Session["CustomerId"].ToString()); int babyid = unitOfWork.adsBabysRepository.Get(filter: u => u.CustomerId == customerId && u.Babystatus == true).First().BabyId; Message msg = new Message(); Baogao baogao = new Baogao(); baogao.BaogaoScore = score; baogao.BaogaoDementionScore = Dementionscore; baogao.BaogaoTotalScore = totalscore; baogao.BaogaoWeight = PlanServices.MakePlan(weight); baogao.CustomerId = customerId; baogao.BabyId = babyid; baogao.ScaleId = 1; baogao.BaogaoTime = System.DateTime.Now; try { unitOfWork.baogaoRepository.Insert(baogao); unitOfWork.Save(); msg.MessageStatus = "true"; msg.MessageInfo = baogao.BaogaoId.ToString(); } catch { msg.MessageStatus = "false"; msg.MessageInfo = "保存失败"; } return(Json(msg, JsonRequestBehavior.AllowGet)); }