public void Create(Report report) { using (PhoneshopContext context = new PhoneshopContext()) { context.Reports.Add(report); context.SaveChanges(); } }
public ActionResult Upload(HttpPostedFileBase upload) { Report report = new Report { UploadDate = DateTime.Today, Filename = upload.FileName, FileMIMEType = upload.ContentType }; using (MemoryStream ms = new MemoryStream()) { upload.InputStream.CopyTo(ms); report.FileBytes = ms.GetBuffer(); } _reportRepository.Create(report); return RedirectToAction("Index"); }