public ActionResult EditArts(EditModel model, HttpPostedFileBase upload, int Id)
        {
            if (upload != null)
            {
                string fileName = System.IO.Path.GetFileName(upload.FileName);
                upload.SaveAs(Server.MapPath("~/Files/" + fileName));
                int photoId;
                using (ArtContext db1 = new ArtContext())
                {
                    PhotoArt p1 = new PhotoArt {
                        PhotoName = fileName, Photo = Server.MapPath("~/ Files / " + fileName)
                    };
                    db1.PhotoArts.Add(p1);
                    db1.SaveChanges();
                    photoId = p1.Id;
                    ArtWork artWork = db1.ArtWorks.Where(p => p.Id == Id).FirstOrDefault();
                    artWork.PhotoArtId = photoId;
                    db1.SaveChanges();
                }
            }
            else
            {
                db.Entry(model.ArtWorks).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("ListArts"));
        }
 public ActionResult UploadPhoto(PhotoArt photo, HttpPostedFileBase upload)
 {
     if (upload != null)
     {
         string fileName = System.IO.Path.GetFileName(upload.FileName);
         upload.SaveAs(Server.MapPath("~/Files/" + fileName));
         using (ArtContext db = new ArtContext())
         {
             PhotoArt p1 = new PhotoArt {
                 PhotoName = fileName, Photo = Server.MapPath("~/ Files / " + fileName)
             };
             db.PhotoArts.Add(p1);
             db.SaveChanges();
         }
     }
     return(RedirectToAction("ListArts"));
 }