public ActionResult Delete(int id, string returnURL) { if (Session["admin"] != null) { StyleThird styleThird = db.StyleThird.Find(id); db.StyleThird.Remove(styleThird); StyleDetails styleDetail = db.StyleDetails.Find(styleThird.StyleDetailId); string styleId = styleDetail.StyleId.ToString(); UpdateRecord record = db.UpdateRecord.Where(item => item.StyleId == styleId).FirstOrDefault(); if (record != null) { record.UpdateTime = DateTime.Now; db.Entry(record).State = EntityState.Modified; } else { record = new UpdateRecord(); record.StyleId = styleId; record.UpdateTime = DateTime.Now; db.UpdateRecord.Add(record); } db.SaveChanges(); return(Redirect(returnURL)); } else { return(RedirectToAction("Login", "Console")); } }
public ActionResult DIYDetail(int id) { if (Session["admin"] != null) { DIYResult result = db.DIYResult.Find(id); StyleThird styleThird = db.StyleThird.Find(result.StyleDetailId); ViewBag.styleCode = styleThird.StyleThirdCode; ViewBag.styleResource = styleThird.StyleResource; return(View(result)); } else { return(RedirectToAction("Login", "Console")); } }
public ActionResult DIYDetail(int id) { if (Session["userName"] != null) { var diyResult = db.DIYResult.Find(id); StyleThird styleThird = db.StyleThird.Find(diyResult.StyleDetailId); ViewBag.styleCode = styleThird.StyleThirdCode; ViewBag.styleResource = styleThird.StyleResource; return(View(diyResult)); } else { return(RedirectToAction("Login", "Home")); } }
public ActionResult SavEdit(StyleThird styleThird, bool IsCreate) { if (Session["admin"] != null) { styleThird.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); styleThird.StyleThirdIndex = ToSmall(styleThird.StyleThirdIndex); StringBuilder sb = new StringBuilder(); string[] pics = styleThird.StyleThirdPics.Substring(0, styleThird.StyleThirdPics.Length - 1).Split(' '); foreach (var pic in pics) { sb.Append(ToSmall(pic)); sb.Append(" "); } styleThird.StyleThirdPics = sb.ToString(); if (IsCreate) { db.Entry(styleThird).State = EntityState.Modified; } else { db.StyleThird.Add(styleThird); } db.SaveChanges(); StyleDetails styleDetail = db.StyleDetails.Find(styleThird.StyleDetailId); string styleId = styleDetail.StyleId.ToString(); UpdateRecord record = db.UpdateRecord.Where(item => item.StyleId == styleId).FirstOrDefault(); if (record != null) { record.UpdateTime = DateTime.Now; db.Entry(record).State = EntityState.Modified; } else { record = new UpdateRecord(); record.StyleId = styleId; record.UpdateTime = DateTime.Now; db.UpdateRecord.Add(record); } db.SaveChanges(); return(RedirectToAction("List", new { id = styleThird.StyleDetailId })); } else { return(RedirectToAction("Login", "Console")); } }
public ActionResult Edit(int id) { if (Session["admin"] != null) { ViewBag.IsCreate = true; StyleThird styleThird = db.StyleThird.Find(id); StyleDetails styleDetail = db.StyleDetails.Find(styleThird.StyleDetailId); ViewBag.StyleDetailName = styleDetail.StyleDetailName; ViewBag.StyleDetailId = styleDetail.Id; Styles style = db.Styles.Find(styleDetail.StyleId); ViewBag.StyleName = style.StyleName; ViewBag.StyleId = style.Id; return(View(styleThird)); } else { return(RedirectToAction("Login", "Console")); } }