public ActionResult fileUpload(FormCollection formCollection) { int InkId = int.Parse(formCollection["AttachmentID"]); if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/IssueImage/"), fileName); if (System.IO.File.Exists(path)) { TempData["ImageExist"] = "ImageExist"; return(RedirectToAction("Index", "IssueInk")); } else { file.SaveAs(path); IssueInk issueInk = db.IssueInks.Find(InkId); issueInk.Attachment = fileName; db.Entry(issueInk).State = EntityState.Modified; db.SaveChanges(); //Saving Changes } } } return(RedirectToAction("Index", "IssueInk")); }
private void DropIssueInk(int?Id) { IssueInk OissueInk = db.IssueInks.Find(Id); updateQuantity(OissueInk.InkId, true, OissueInk.Quantity); // adding the ink back to store - as we are passing true in operations db.IssueInks.Remove(OissueInk); db.SaveChanges(); }
public void setNullToAttachment(int?id) { IssueInk issueInk = db.IssueInks.Find(); issueInk.Attachment = null; db.Entry(issueInk).State = EntityState.Modified; db.SaveChanges(); }
public ActionResult LinkUpdate(FormCollection formCollection) { int InkId = int.Parse(formCollection["linkAttachmentID"]); var fileName = formCollection["searchFileNamesList"]; IssueInk issueInk = db.IssueInks.Find(InkId); issueInk.Attachment = fileName; db.Entry(issueInk).State = EntityState.Modified; db.SaveChanges(); //Saving Changes return(RedirectToAction("Index", "IssueInk")); }
public ActionResult Index(IssueInk iInk, FormCollection formCollection) { string employeeName = formCollection["nameList"]; // got the Value of the Employee textbox from the form and stored in variable of type string iInk.Employee = employeeName; //Stored Employee Name int InkidNumber = int.Parse(formCollection["modelList"]); iInk.InkId = InkidNumber; updateQuantity(InkidNumber, false, iInk.Quantity); iInk.date = DateTime.Now; db.IssueInks.Add(iInk); //Adding iInk Model to pass data in database db.SaveChanges(); // Saving Changes return(View()); }