public ActionResult CreateImage(Picture picture, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {

                if (file != null)
                {

                    // Получаем имя файла
                    string ImageName = System.IO.Path.GetFileName(file.FileName);
                    // сохраняем файл по определенному пути на сервере
                    string physicalPath = Server.MapPath("~/Files/foto/" + ImageName);
                    //сохраняэм файл в папку
                    file.SaveAs(physicalPath);
                    //получаем id користувача
                    var id = Membership.GetUser().ProviderUserKey;
                    Picture newRecord = new Picture();

                    newRecord.UserId =(int) id;
                    newRecord.File = ImageName;
                    dataManager.Pictures.SavePicture(newRecord);

                }

                return RedirectToAction("Index","Home");
            }
            return View(picture);
        }
        public void SavePicture(Picture picture)
        {
            if (picture.Id == 0)
            {
                context.Pictures.Add(picture);
            }
            else
            {
                Picture dbEntry = context.Pictures.Find(picture.Id);
                if (dbEntry != null)
                {

                    dbEntry.File = picture.File;
                }

            }
            context.SaveChanges();
        }
 public void DeletePicture(Picture pictures)
 {
     _context.Pictures.Remove(pictures);
     //_context.SaveChanges();
 }