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());
            }
        }
Esempio n. 2
0
        public int Getlistidexposure(int id)
        {
            List <space>      listsp = new List <space>();
            ShowroomdbContext cnx    = new ShowroomdbContext();
            var List = new List <details>();

            //var list = ut.getRepository<details>().GetMany(a => a.exposure_id == id);
            foreach (var x in cnx.details)
            {
                if (x.exposure_id == id)
                {
                    List.Add(x);
                }
            }

            foreach (details x in List)
            {
                if (!listsp.Contains(sp.GetById(x.fk_space)))
                {
                    listsp.Add(sp.GetById(x.fk_space));
                }
            }

            return(listsp.Count);
        }
        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 DeleteConfirm(int id, FormCollection collection)
        {
            ShowroomdbContext cnt = new ShowroomdbContext();
            space             s   = service.GetById(id);

            service.Delete(s);
            service.Commit();
            //cnt.spaces.Remove(s);
            //cnt.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Exposure/Details/5
        public ActionResult Details(int id)
        {
            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IEnumerable <artwork>          ListArtworkById = serviceA.ArtworkByIdArtwork(id);
            List <ArtworkForExposureModel> ArtById         = new List <ArtworkForExposureModel>();

            ShowroomdbContext ctx = new ShowroomdbContext();


            //user Artist = ServiceU.GetById(u.fk_artist.Value);
            //ExpositionArtwork ExpositionArtwork = ServicExpositionArtwork.GetOneExpoByIdExpo(id);
            //space space = ServiceS.GetById(ExpositionArtwork.fk_space);
            //exposure exposure = service.GetById(id);
            //int? FkOwner = space.fk_owner;
            //user Owner = ServiceU.GetById(FkOwner.Value);

            if (ListArtworkById == null)
            {
                return(HttpNotFound());
            }

            foreach (var x in ListArtworkById)
            {
                ArtworkForExposureModel ar = new ArtworkForExposureModel();

                user Artist = ServiceU.GetById((int)x.artist_id);
                ExpositionArtwork ExpositionArtwork = ServicExpositionArtwork.GetOneExpoByIdExpo(id);
                space             space             = ServiceS.GetById(ExpositionArtwork.fk_space);
                exposure          exposure          = service.GetById(id);
                int? FkOwner = space.owner_id;
                user Owner   = ServiceU.GetById(FkOwner.Value);
                ar.id           = x.id;
                ar.name         = x.name;
                ar.photo        = x.phot;
                ar.ArtistName   = Artist.firstName + Artist.lastName;
                ar.StartDate    = exposure.SDate.Value;
                ar.EndDate      = exposure.EDate.Value;
                ar.SpaceName    = space.name;
                ar.SpaceAddress = space.adress;
                ar.OwnerName    = Owner.firstName + Owner.lastName;
                ar.Priority     = ServicExpositionArtwork.GetByIdArtworkAndIdExposure(id, x.id);
                ArtById.Add(ar);
            }


            return(View(ArtById.OrderBy(a => a.Priority).ToList()));
        }
Esempio n. 7
0
        public void Archiver()
        {
            ShowroomdbContext cnx = new ShowroomdbContext();
            var a = ut.getRepository <exposure>().GetMany().ToList();

            foreach (var x in a)
            {
                if (x.EDate == DateTime.Now)
                {
                    x.Archiver = true;
                }
                else
                {
                    x.Archiver = false;
                }

                ut.getRepository <exposure>().Update(x);
                ut.Commit();
            }
        }
        // GET: Exposure/Create
        public ActionResult Create()
        {
            #region Initialisation
            ExposureModel     ExpoM = new ExposureModel();
            ShowroomdbContext ctx   = new ShowroomdbContext();
            var z = serviceA.GetArtworkByIdArtist((int)@Session["LogedUserid"]);
            ExpoM.ArtworksOfArtist = z;
            foreach (var x in ExpoM.ArtworksOfArtist)
            {
                Debug.WriteLine("aaaaaaaaaaaaa" + x.name);
            }
            // ExpoM.Spaces = ServiceS.GetAllSpaves.ToSelectListItems();

            //ViewBag.Spaces = ServiceS.GetMany().Select(x => new SelectListItem {Text = x.name,Value = x.id.ToString()});
            List <space> listSpace = new List <space>();

            #endregion



            return(View(ExpoM));
        }
        // GET: Artwork
        public ActionResult Index()
        {
            IEnumerable <artwork> ListArtwork       = service.GetMany();
            List <ArtworkModels>  ListArtworkModels = new List <ArtworkModels>();



            ShowroomdbContext cnx = new ShowroomdbContext();

            foreach (artwork ar in cnx.artworks)
            {
                var am = new ArtworkModels();
                am.id          = ar.id;
                am.description = ar.description;
                am.name        = ar.name;
                am.photo       = ar.phot;


                ListArtworkModels.Add(am);
            }
            return(View(ListArtworkModels));
        }
        // GET: Exposure
        public ActionResult Index()
        {
            IEnumerable <exposure> ListExposure        = service.GetMany();
            List <ExposureModel>   ListExpositionModel = new List <ExposureModel>();
            //service.Archiver();
            ShowroomdbContext cnx = new ShowroomdbContext();


            foreach (exposure ex in cnx.exposures)
            {
                ExposureModel em = new ExposureModel();
                em.id        = ex.id;
                em.startDate = ex.SDate;
                em.endDate   = ex.EDate;
                em.name      = ex.name;
                if (!ex.Archiver)
                {
                    ListExpositionModel.Add(em);
                }
            }

            return(View(ListExpositionModel));
        }
        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 ActionResult Create(ExposureModel exM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    #region Intialisation
                    ShowroomdbContext ctx  = new ShowroomdbContext();
                    exposure          Expo = new exposure();
                    List <artwork>    la   = new List <artwork>();

                    List <ArtworkForExposureModel> ArtForExpo = new List <ArtworkForExposureModel>();
                    ExpositionArtwork ar = new ExpositionArtwork();
                    #endregion
                    #region PopulateExposition
                    Expo.id       = exM.id;
                    Expo.SDate    = exM.startDate;
                    Expo.EDate    = exM.endDate;
                    Expo.name     = exM.name;
                    Expo.Archiver = false;
                    service.Add(Expo);
                    service.Commit();
                    #endregion
                    #region PopulateExposureArtworks

                    var a = exM.Order;

                    Debug.WriteLine(a);

                    int IdEpo = (service.GetIdByName(Expo.name));

                    Debug.WriteLine(IdEpo);
                    DateTime DatePriority = DateTime.Now;
                    Debug.WriteLine(DatePriority);
                    int      FkSpace    = 1;
                    String[] Priorities = a.Split(',');
                    for (int i = 0; i < Priorities.Length; i++)
                    {
                        Debug.WriteLine("idddddddddds" + Priorities[i]);
                        Debug.WriteLine("priiiiiiot" + (i + 1));
                    }

                    for (int i = 0; i < Priorities.Length; i++)
                    {
                        ExpositionArtwork EA = new ExpositionArtwork();
                        EA.exposureId       = IdEpo;
                        EA.DateExpoPriority = DatePriority;
                        EA.fk_space         = FkSpace;
                        EA.artworkId        = Convert.ToInt32(Priorities[i]);
                        EA.Priority         = i + 1;
                        ServiceArt.Add(EA);
                        ServiceArt.Commit();
                    }



                    #endregion

                    return(RedirectToAction("Index"));
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 13
0
 public DatabaseFactory()
 {
     dataContext = new ShowroomdbContext();
 }
 public UnitOfWork(IDatabaseFactory dbFactory)
 {
     this.dbFactory = dbFactory;
     dataContext    = dbFactory.DataContext;
 }