public Report Get(int id)
 {
     using (PhoneshopContext context = new PhoneshopContext())
     {
         return context.Reports.FirstOrDefault(r => r.Id == id);
     }
 }
 public List<Report> List()
 {
     using (PhoneshopContext context = new PhoneshopContext())
     {
         return context.Reports.ToList();
     }
 }
 public void Create(Report report)
 {
     using (PhoneshopContext context = new PhoneshopContext())
     {
         context.Reports.Add(report);
         context.SaveChanges();
     }
 }
 public FileResult GetItemImage(int id)
 {
     using (PhoneshopContext context = new PhoneshopContext())
     {
         Item item = context.Items.FirstOrDefault(i => i.Id == id);
         return item?.ImageBytes != null ? File(item.ImageBytes, item.ImageMIMEType) : null;
     }
 }
        public ActionResult Create([Bind(Exclude = "Id")] ItemCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                Item item = new Item {Name = model.Name, Description = model.Description, Price = model.Price};
                using (MemoryStream ms = new MemoryStream())
                {
                    model.Image.InputStream.CopyTo(ms);
                    item.ImageBytes = ms.GetBuffer();
                }
                item.ImageMIMEType = model.Image.ContentType;

                using (PhoneshopContext context = new PhoneshopContext())
                {
                    context.Items.Add(item);
                    context.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            return View(model);
        }