public void DeleteNeById(int id) { NetherGarment ne = db.NetherGarment.Where(s => s.NetherGarmentID == id).FirstOrDefault(); if (ne != null) { db.NetherGarment.Remove(ne); } db.SaveChanges(); }
public ActionResult AddClothes(FormCollection col) { Suit suit = new Suit(); Coat coat = new Coat(); NetherGarment ne = new NetherGarment(); Shirt shirt = new Shirt(); string color = col["color"]; string yizong = col["yifu"]; string season = col["season"]; string material = col["material"]; var img = Request.Files["imgFile"]; string path = Guid.NewGuid().ToString() + img.FileName; switch (yizong) { case "衬衫": case "连帽卫衣": case "圆领卫衣": case "T恤": case "吊带": shirt.Color = color; shirt.Design = yizong; shirt.Image = "../shirt/" + path; shirt.Material = material; shirt.Season = season; shirt.Time = DateTime.Now; shirt.WardrobeID = 1; shirts.AddShirt(shirt); img.SaveAs(Request.MapPath("/Images/shirt/" + path)); break; case "棒球服": case "风衣": case "针织开衫": case "牛仔": case "西装": coat.Color = color; coat.Design = yizong; coat.Image = "../Coat/" + path; coat.Material = material; coat.Season = season; coat.Time = DateTime.Now; coat.WardrobeID = 1; coats.AddCoat(coat); img.SaveAs(Request.MapPath("/Images/Coat/" + path)); break; case "超短裤": case "短裤": case "中长裙": case "长裤": ne.Color = color; ne.Design = yizong; ne.Image = "../NetherGarment/" + path; ne.Material = material; ne.Season = season; ne.Time = DateTime.Now; ne.WardrobeID = 1; nethers.AddNether(ne); img.SaveAs(Request.MapPath("/Images/NetherGarment/" + path)); break; case "套装": suit.Color = color; suit.Design = yizong; suit.Image = "../Suit/" + path; suit.Material = material; suit.Season = season; suit.Time = DateTime.Now; suit.WardrobeID = 1; suits.AddSuit(suit); img.SaveAs(Request.MapPath("/Images/Suit/" + path)); break; } return(Content("<script>alert('添加成功');history.go(-1);</script>")); }
//添加下衣 public void AddNether(NetherGarment nether) { inether.AddNether(nether); }
public void AddNether(NetherGarment nether) { db.NetherGarment.Add(nether); db.SaveChanges(); }