public string sendRequireDetail( RequiredPostViewModel_C rp) { try { RequiredPost post = requiredPostRepository.GetbyID(rp.RequiredPostID); post.postDescription = rp.postDescription; post.postName = rp.postName; post.requiredQTY = rp.requiredQTY; post.TagID = rp.TagID; post.estimatePrice = rp.estimatePrice; post.OrderID = rp.OrderID; post.county = rp.county; post.district = rp.district; post.address = rp.address; post.isPast = false; post.postTime = DateTime.Now; post.UserID = Convert.ToInt32(Request.Cookies["LoginAccount"].Value); requiredPostRepository.Update(post); if (rp.upphoto != null) { string filename = rp.upphoto.FileName; rp.upphoto.SaveAs(Server.MapPath("../Content/resource_nico/images/徵求台POST/") + filename); string filePath = $"../Content/resource_nico/images/徵求台POST/{filename}"; } return "修改成功"; } catch (Exception e) { return "修改失敗"; } }
public string sendRequiredPost(RequiredPostViewModel_C rp) { RequiredPost post = new RequiredPost() { postDescription = rp.postDescription, postName = rp.postName, postImg = rp.upphoto.FileName, requiredQTY = rp.requiredQTY, TagID = rp.TagID, estimatePrice = rp.estimatePrice, OrderID = rp.OrderID, county = rp.county, district = rp.district, address=rp.address, isPast = false }; post.postTime = DateTime.Now; post.UserID = Convert.ToInt32(Request.Cookies["LoginAccount"].Value); requiredPostRepository.Create(post); if (rp.upphoto == null) { rp.postImg = "無圖示.jpg"; } else { string filename = rp.upphoto.FileName; rp.upphoto.SaveAs(Server.MapPath("../Content/resource_nico/images/徵求台POST/") + filename); string filePath = $"../Content/resource_nico/images/徵求台POST/{filename}"; } return "發文成功"; }