public ActionResult DeleteConfirmed(Guid id) { AnswerAttachment answerAttachment = db.AnswerAttachments.Find(id); db.AnswerAttachments.Remove(answerAttachment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,AnswerId,Created,FileName,MimeType,Size")] AnswerAttachment answerAttachment) { if (ModelState.IsValid) { db.Entry(answerAttachment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(answerAttachment)); }
public ActionResult Create([Bind(Include = "Id,AnswerId,Created,FileName,MimeType,Size")] AnswerAttachment answerAttachment) { if (ModelState.IsValid) { answerAttachment.Id = Guid.NewGuid(); db.AnswerAttachments.Add(answerAttachment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(answerAttachment)); }
// GET: AnswerAttachments/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AnswerAttachment answerAttachment = db.AnswerAttachments.Find(id); if (answerAttachment == null) { return(HttpNotFound()); } return(View(answerAttachment)); }
public static List <AnswerAttachment> TransformToAnswerAttachment(int answerId, IEnumerable <HttpPostedFileBase> files) { var attachments = new List <AnswerAttachment>(); foreach (var file in files) { if (file == null) { continue; } Attachment attachment = GenerateAttachment(file); var answerAttachment = new AnswerAttachment(answerId, attachment); attachments.Add(answerAttachment); } return(attachments); }
public ActionResult Attachment(int id) { AnswerAttachment img = db.AnswerAttachments.Find(id); return(File(img.Data, EnumDescription.Get(img.FileType))); }