public ActionResult Create(SpaceViewModel svm, HttpPostedFileBase upload)
        {
            string userid = this.Session["LogedUserid"].ToString();

            try
            {
                // TODO: Add insert logic here


                if (ModelState.IsValid)
                {
                    ShowroomdbContext ctx = new ShowroomdbContext();
                    space             s   = new space();
                    s.adress      = svm.Adress;
                    s.rentalPrice = svm.Prix;
                    s.description = svm.Description;
                    s.owner_id    = Int32.Parse(userid);
                    if (upload != null && upload.ContentLength > 0)
                    {
                        s.pic = Guid.NewGuid().ToString() + Path.GetFileName(upload.FileName);
                        upload.SaveAs(Path.Combine(Server.MapPath("~/Content/SpaceImages"), s.pic));
                    }
                    ctx.spaces.Add(s);
                    ctx.SaveChanges();
                    //service.Add(s);
                    //service.Commit();
                    return(RedirectToAction("Index"));
                }
                return(View());
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ShowroomdbContext cnx     = new ShowroomdbContext();
            artwork           artwork = cnx.artworks.Find(id);

            cnx.artworks.Remove(artwork);
            cnx.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            ShowroomdbContext ctx = new ShowroomdbContext();
            var x = ctx.exposures.Find(id);

            x.Archiver = true;

            ctx.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(ArtworkModels artwork, HttpPostedFileBase upload)
        {
            try
            {
                // TODO: Add insert logic here



                if (ModelState.IsValid)
                {
                    ShowroomdbContext ctx = new ShowroomdbContext();
                    artwork           a   = new artwork();
                    a.description = artwork.description;
                    a.name        = artwork.name;
                    if (upload != null && upload.ContentLength > 0)
                    {
                        a.phot = Guid.NewGuid().ToString() + Path.GetFileName(upload.FileName);
                        upload.SaveAs(Path.Combine(Server.MapPath("~/Content/ArtworkImages"), a.phot));
                    }


                    a.artist_id = (int)Session["LogedUserid"];
                    Debug.WriteLine((int)Session["LogedUserid"]);
                    a.category_id = 1;
                    ctx.artworks.Add(a);
                    ctx.SaveChanges();
                    // service.Add(a);
                    //service.Commit();
                    return(RedirectToAction("Index"));
                }
                return(View());
            }
            catch
            {
                return(View());
            }
        }
 public void Commit()
 {
     dataContext.SaveChanges();
 }