public ActionResult GetFurnitureData(int styleId) { string id = styleId.ToString(); //UpdateRecord record = db.UpdateRecord.Where(item => item.FurnitureId == id).FirstOrDefault(); //if (record == null) //{ // record = new UpdateRecord(); // record.FurnitureId = id; // record.UpdateTime = DateTime.Now; // db.UpdateRecord.Add(record); // db.SaveChanges(); //} FurnitureStyleData furnitureStyleData = new FurnitureStyleData(); FurnitureStyle furniture = db.FurnitureStyle.Find(styleId); furnitureStyleData.FurnitureId = furniture.Id; furnitureStyleData.FurnitureIndexPic = ConfigurationManager.AppSettings["ResourceUrl"] + furniture.IndexPic; furnitureStyleData.FurniturePic = ConfigurationManager.AppSettings["ResourceUrl"] + furniture.FurniturePics; string[] args = furniture.StyleName.Split('&').ToArray(); furnitureStyleData.FurnitureBrand = args[0]; furnitureStyleData.FurnitureSize = args[1]; furnitureStyleData.FurniturePrize = args[2]; furnitureStyleData.FurnitureMaterial = args[3]; //furnitureStyleData.FurnitureUpdate = record.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss"); int coverId = furniture.StyleId; int companyId = furniture.CompanyId; var notshowdata = db.FStyleID.Where(o => o.CompanyId == companyId).Select(o => o.FStyleId).ToList(); FurnitureStyle preStyle = db.FurnitureStyle.OrderByDescending(item => item.Id).Where(item => item.Id > styleId && (item.StyleId == coverId && (item.CompanyId == companyId || (item.CreateUserId == 1 && !notshowdata.Contains(item.Id))))).OrderBy(item => item.Id).FirstOrDefault(); int pre = 0; if (preStyle != null) { pre = 1; } int next = 0; FurnitureStyle nextStyle = db.FurnitureStyle.OrderByDescending(item => item.Id).Where(item => item.Id < styleId && (item.StyleId == coverId && (item.CompanyId == companyId || (item.CreateUserId == 1 && !notshowdata.Contains(item.Id))))).FirstOrDefault(); if (nextStyle != null) { next = 1; } return(Json(new { pre = pre, data = furnitureStyleData, next = next }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetFurnitureAll(int styleId, int companyId) { string id = styleId.ToString(); UpdateRecord record = db.UpdateRecord.Where(item => item.FurnitureId == id).FirstOrDefault(); if (record == null) { record = new UpdateRecord(); record.FurnitureId = id; record.UpdateTime = DateTime.Now; db.UpdateRecord.Add(record); db.SaveChanges(); } T_FurnitureCover furnitureCover = db.T_FurnitureCover.Find(styleId); var notshowdata = db.FStyleID.Where(o => o.CompanyId == companyId).Select(o => o.FStyleId).ToList(); var fsmodelAll = db.FurnitureStyle.Where(item => item.StyleId == styleId && (item.CompanyId == companyId || (item.CreateUserId == 1 && !notshowdata.Contains(item.Id)))).OrderByDescending(item => item.Id).ToList(); T_FurnitureCoverData furnitureCoverData = new T_FurnitureCoverData(); furnitureCoverData.FurnitureCoverId = furnitureCover.Id; furnitureCoverData.FurnitureCoverName = furnitureCover.StyleName; furnitureCoverData.FurnitureCoverIndex = ConfigurationManager.AppSettings["ResourceUrl"] + furnitureCover.StylePic; furnitureCoverData.FurnitureCoverUpdate = record.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss"); List <FurnitureStyleData> furnitureStyleList = new List <FurnitureStyleData>(); foreach (FurnitureStyle furnitureStyle in fsmodelAll) { FurnitureStyleData furnitureStyleData = new FurnitureStyleData(); furnitureStyleData.FurnitureId = furnitureStyle.Id; furnitureStyleData.FurnitureIndexPic = ConfigurationManager.AppSettings["ResourceUrl"] + furnitureStyle.IndexPic; furnitureStyleData.FurniturePic = ConfigurationManager.AppSettings["ResourceUrl"] + furnitureStyle.FurniturePics; string[] args = furnitureStyle.StyleName.Split('&').ToArray(); furnitureStyleData.FurnitureBrand = args[0]; furnitureStyleData.FurnitureSize = args[1]; furnitureStyleData.FurniturePrize = args[2]; furnitureStyleData.FurnitureMaterial = args[3]; furnitureStyleList.Add(furnitureStyleData); } furnitureCoverData.FurnitureStyleData = furnitureStyleList; return(Json(new { data = furnitureCoverData }, JsonRequestBehavior.AllowGet)); }