public ActionResult sendContent(SendContend send) { String fileName = (String)Session["fileUpload"]; String WordFileName = (String)Session["WordFileUpload"]; String userName = (String)Session["User"]; DateTime uploadDate = DateTime.Today; uploadDate.ToString("d"); send.uploaddDate = uploadDate; var query = from q in db.Accounts where q.userName == userName select q.userID; send.userID = query.First(); send.comment = ""; send.contendStatus = "new"; send.wordContend = "~/docx/" + WordFileName; send.imageContend = "~/ImageFile/" + fileName; db.SendContends.Add(send); db.SaveChanges(); ViewBag.Success = "One Post has been added"; return(View("Success")); }
public ActionResult DoEdit(SendContend changeContend) { var Contend = db.SendContends.SingleOrDefault(c => c.id == changeContend.id); String status = Request["chooseStatus"]; Contend.comment = changeContend.comment; Contend.contendStatus = status; db.SaveChanges(); return(View("Success")); }
public ActionResult DoEdit(SendContend changeContend) { var Contend = db.SendContends.SingleOrDefault(c => c.id == changeContend.id); Contend.contendStatus = "Changed"; HttpPostedFileBase file = Request.Files["file"]; HttpPostedFileBase file1 = Request.Files["file1"]; if (file.ContentLength > 0 && file1.ContentLength > 0) { string _FileName = Path.GetFileName(file.FileName); string _path = Path.Combine(Server.MapPath("~/ImageFile"), _FileName); file.SaveAs(_path); Contend.imageContend = "~/ImageFile/" + _FileName; string _FileName1 = Path.GetFileName(file1.FileName); string _path1 = Path.Combine(Server.MapPath("~/docx"), _FileName1); file1.SaveAs(_path1); Contend.wordContend = "~/docx/" + _FileName1; db.SaveChanges(); } else if (file.ContentLength > 0) { string _FileName = Path.GetFileName(file.FileName); string _path = Path.Combine(Server.MapPath("~/ImageFile"), _FileName); file.SaveAs(_path); Contend.imageContend = "~/ImageFile/" + _FileName; db.SaveChanges(); } else if (file1.ContentLength > 0) { string _FileName1 = Path.GetFileName(file1.FileName); string _path1 = Path.Combine(Server.MapPath("~/docx"), _FileName1); file1.SaveAs(_path1); Contend.wordContend = "~/docx/" + _FileName1; db.SaveChanges(); } else { db.SaveChanges(); } return(View("Success")); }