コード例 #1
0
 public void Create(Report report)
 {
     using (PhoneshopContext context = new PhoneshopContext())
     {
         context.Reports.Add(report);
         context.SaveChanges();
     }
 }
コード例 #2
0
        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");
        }