public ActionResult MaterialInfo(string id) { Material_Info materialInfo = _infoBll.GetEntity(m => m.Material_Id == id && m.Is_Show == true); Stack <string> materType = new Stack <string>(); materType.Push(materialInfo.Material_Type_Name); GetAllTypes(materType, materialInfo.Material_Type_Name); ViewBag.Title = materialInfo.Material_Name; ViewBag.AllTypes = materType; return(View(materialInfo)); }
public FileContentResult GetImage(string id) { Material_Info info = _infoBll.GetEntity(m => m.Material_Id == id && m.Is_Show == true); if (info != null) { return(new FileContentResult(info.Material_Image, "Image/jpg")); } else { return(null); } }
public string SelfApplyInComing(Material_Info materialInfo, int applyCount) { if (_baseInfoBll.GetEntities(m => m.Material_Id == materialInfo.Material_Id) == null) { materialInfo.Material_Count = 0; materialInfo.Material_RemainCont = 0; materialInfo.Is_Show = false; if (_baseInfoBll.AddBaseInfo(materialInfo) != "添加成功") { return("Error"); } } BuyInComing_Apply buyInComingApply = new BuyInComing_Apply() { Material_Id = materialInfo.Material_Id, Is_InComed = false, Is_Bought = false, Last_Time = DateTime.MaxValue }; if (_buyInComingApplyBll.AddEntities(new List <BuyInComing_Apply>() { buyInComingApply })) { Apply_Info applyInfo = new Apply_Info { Apply_Id = buyInComingApply.Id, ApplyType_Id = "002", Apply_Count = applyCount, Apply_Status = 0 }; if (_applyInfoBll.AddEntities(new List <Apply_Info> { applyInfo })) { return("OK"); } } return("Error"); }
public ActionResult Apply(string id, string count) { Dictionary <Material_Info, string> infos = new Dictionary <Material_Info, string>(); var cookie = Request.Cookies["userInfo"]; if (cookie != null) { string name = cookie.Value; var user = JsonConvert.DeserializeObject <UserInfo>(UrlHelper.DecodeUrl(name)); var teacher = UnityContainerHelper.Server <ITeacherBll>().Find(user.username); ViewBag.teacher = teacher; } if (id == null && count == null) { if (Session["materialCar"] == null) { return(Content("我的器材为空")); } if (Session["materialCar"] is Dictionary <string, int> carInfos) { foreach (string carInfosKey in carInfos.Keys) { Material_Info info = _infoBll.GetEntity(m => m.Material_Id == carInfosKey); int buyCount = carInfos[carInfosKey] > Int32.Parse(info.Material_RemainCont.ToString()) ? carInfos[carInfosKey] - Int32.Parse(info.Material_RemainCont.ToString()) : 0; string counts = carInfos[carInfosKey] + ":" + buyCount; infos.Add(info, counts); } } } else { Material_Info materialInfo = _infoBll.GetEntity(m => m.Material_Id == id); ViewBag.materialInfo = materialInfo; var buyCount = Int32.Parse(count) > Int32.Parse(materialInfo.Material_RemainCont.ToString()) ? Int32.Parse(count) - Int32.Parse(materialInfo.Material_RemainCont.ToString()) : 0; infos.Add(materialInfo, count + ":" + buyCount); if (Session["materialCar"] == null) { var carInfos = new Dictionary <string, int> { { id, int.Parse(count) } }; Session["materialCar"] = carInfos; } else { if (Session["materialCar"] is Dictionary <string, int> carInfos) { if (carInfos.ContainsKey(id)) { carInfos[id] += int.Parse(count); } else { carInfos.Add(id, int.Parse(count)); } Session["materialCar"] = carInfos; } } } ViewBag.materialInfos = infos; var model = new Material_Apply(); return(View(model)); }