Exemplo n.º 1
0
        // GET: KinderGarten/Delete/5
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KinderGarten      p  = KindergartenService.GetById(id);
            KinderGartenModel p1 = new KinderGartenModel()
            {
                Name    = p.Name,
                Image   = p.Image,
                Address = p.Address,
                NbrEmp  = p.NbrEmp,
                Cost    = p.Cost,

                Phone       = p.Phone,
                Description = p.Description,
            };

            if (p == null)
            {
                return(HttpNotFound());
            }
            return(View(p1));
        }
Exemplo n.º 2
0
        public ActionResult Delete(int id, KinderGartenModel evm)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KinderGarten p = KindergartenService.GetById(id);

            evm = new KinderGartenModel()
            {
                Name        = p.Name,
                Image       = p.Image,
                Address     = p.Address,
                NbrEmp      = p.NbrEmp,
                Cost        = p.Cost,
                Phone       = p.Phone,
                Description = p.Description,
            };
            if (p == null)
            {
                return(HttpNotFound());
            }
            Console.WriteLine("deletedddddddddddddddddddddddddddddddd");
            KindergartenService.Delete(p);
            KindergartenService.Commit();
            // Service.Dispose();

            return(RedirectToAction("Index"));
        }
        public IHttpActionResult Put(int id, KinderGartenModel kgm)
        {
            KinderGarten kg = MyService.GetById(id);

            if (kg != null)
            {
                kg.Address     = kgm.Address;
                kg.Description = kgm.Description;
                kg.Cost        = kgm.Cost;
                kg.Name        = kgm.Name;
                kg.NbrEmp      = kgm.NbrEmp;
                kg.Phone       = kgm.Phone;
                kg.Image       = kgm.Image;
                kg.longitude   = kgm.longitude;
                kg.latitude    = kgm.latitude;
                MyService.Update(kg);
                MyService.Commit();
            }
            else
            {
                return(NotFound());
            }


            return(Ok());
        }
        public IHttpActionResult Create(KinderGartenModel kgm)
        {
            using (var ctx = new PidevContext())
            {
                ctx.KinderGartens.Add(new KinderGarten()
                {
                    Name         = kgm.Name,
                    Image        = kgm.Image,
                    Address      = kgm.Address,
                    NbrEmp       = kgm.NbrEmp,
                    Cost         = kgm.Cost,
                    Phone        = kgm.Phone,
                    Description  = kgm.Description,
                    DirecteurId  = kgm.DirecteurId,
                    DateCreation = DateTime.Now,
                    latitude     = kgm.latitude,
                    longitude    = kgm.longitude,
                    Votes        = "0,0,0,0,0"
                });

                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges

                ctx.SaveChanges();
            }

            return(Ok());
        }
Exemplo n.º 5
0
        // GET: KinderGarten
        public ActionResult Index(string searchString)
        {
            var    userId = (int)Session["idu"];
            String Phone2 = userService.GetById(userId).login;
            String mail   = userService.GetById(userId).email;

            ViewBag.home  = mail;
            ViewBag.phone = Phone2;
            var kindergartens = new List <KinderGartenModel>();

            foreach (KinderGarten k in KindergartenService.SearchKindergartenByName(searchString))
            {
                KinderGartenModel ks = new KinderGartenModel()
                {
                    Address        = k.Address,
                    Cost           = k.Cost,
                    DateCreation   = k.DateCreation,
                    Description    = k.Description,
                    KinderGartenId = k.KinderGartenId,
                    Image          = k.Image,
                    Name           = k.Name,
                    NbrEmp         = k.NbrEmp,
                    Phone          = k.Phone,
                    DirecteurId    = k.DirecteurId
                };
                kindergartens.Add(ks);
            }


            return(View(kindergartens));
        }
Exemplo n.º 6
0
        public ActionResult Delete(int id, KinderGartenModel tm)
        {
            KinderGarten t = KindergartenService.GetById(id);

            KindergartenService.Delete(t);
            KindergartenService.Commit();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        // GET: KinderGarten/Details/5
        public ActionResult Details(int?id)
        {
            bool test = HasVoted(id);

            ViewBag.test = test;
            int userId;

            try { userId = (int)Session["idu"]; }
            catch
            {
                return(RedirectToAction("Login", "Login"));
            }

            String Phone2 = userService.GetById(userId).login;
            String mail   = userService.GetById(userId).email;

            ViewBag.home  = mail;
            ViewBag.phone = Phone2;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KinderGarten k;

            k = KindergartenService.GetById((int)id);
            if (k == null)
            {
                return(HttpNotFound());
            }
            KinderGartenModel ks = new KinderGartenModel()
            {
                Address        = k.Address,
                Cost           = k.Cost,
                DateCreation   = k.DateCreation,
                Description    = k.Description,
                KinderGartenId = k.KinderGartenId,
                Image          = k.Image,
                Name           = k.Name,
                NbrEmp         = k.NbrEmp,
                Phone          = k.Phone,
                DirecteurId    = (int)k.DirecteurId,
                nbVue          = k.nbVue,
                nameDir        = userService.GetById((int)k.DirecteurId).email,
                Votes          = k.Votes
            };

            KindergartenService.IncNbVue(id);
            return(View(ks));
        }
Exemplo n.º 8
0
        // GET: KinderGarten/Edit/5
        public ActionResult Edit(int id)
        {
            KinderGarten      t  = KindergartenService.GetById(id);
            KinderGartenModel tm = new KinderGartenModel();

            tm.Name = t.Name;
            //ImageUrl = Image.FileName,
            tm.DateCreation = t.DateCreation;
            tm.Address      = t.Address;
            tm.Cost         = t.Cost;
            tm.Description  = t.Description;
            tm.Phone        = t.Phone;
            tm.NbrEmp       = t.NbrEmp;
            return(View(tm));
        }
Exemplo n.º 9
0
        // GET: KinderGarten/Edit/5
        public ActionResult Edit(int id)
        {
            int    userId = (int)Session["idu"];
            String Phone2 = userService.GetById(userId).login;
            String mail   = userService.GetById(userId).email;


            ViewBag.home  = mail;
            ViewBag.phone = Phone2;
            KinderGarten      t  = KindergartenService.GetById(id);
            KinderGartenModel tm = new KinderGartenModel();

            tm.Name        = t.Name;
            tm.Image       = t.Image;
            tm.Address     = t.Address;
            tm.Cost        = t.Cost;
            tm.Description = t.Description;
            tm.Phone       = t.Phone;
            tm.NbrEmp      = t.NbrEmp;
            return(View(tm));
        }
Exemplo n.º 10
0
        public ActionResult Create(KinderGartenModel km, HttpPostedFileBase Image)
        {
            KinderGarten kg = new KinderGarten();

            kg.Name         = km.Name;
            kg.Image        = Image.FileName;
            kg.DateCreation = DateTime.UtcNow;
            kg.Address      = km.Address;
            kg.Cost         = km.Cost;
            kg.Description  = km.Description;
            kg.NbrEmp       = km.NbrEmp;
            kg.Phone        = km.Phone;
            kg.DirecteurId  = (int)Session["idu"];

            KindergartenService.Add(kg);
            KindergartenService.Commit();

            var path2 = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName);

            Image.SaveAs(path2);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 11
0
        public ActionResult Edit(int id, KinderGartenModel tm, HttpPostedFileBase Image)
        {
            try
            {
                KinderGarten t = KindergartenService.GetById(id);
                t.Name        = tm.Name;
                t.Image       = Image.FileName;
                t.Description = tm.Description;
                t.NbrEmp      = tm.NbrEmp;
                t.Phone       = tm.Phone;
                t.Address     = tm.Address;
                t.Cost        = tm.Cost;

                var path = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName);
                Image.SaveAs(path);
                KindergartenService.Update(t);
                KindergartenService.Commit();
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(tm));
            }
        }
Exemplo n.º 12
0
        // GET: KinderGarten/Details/5
        public ActionResult Details(int?id)
        {
            var    userId = (int)Session["idu"];
            String Phone2 = userService.GetById(userId).login;
            String mail   = userService.GetById(userId).email;

            ViewBag.home  = mail;
            ViewBag.phone = Phone2;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KinderGarten k;

            k = KindergartenService.GetById((int)id);
            if (k == null)
            {
                return(HttpNotFound());
            }
            KinderGartenModel ks = new KinderGartenModel()
            {
                Address        = k.Address,
                Cost           = k.Cost,
                DateCreation   = k.DateCreation,
                Description    = k.Description,
                KinderGartenId = k.KinderGartenId,
                Image          = k.Image,
                Name           = k.Name,
                NbrEmp         = k.NbrEmp,
                Phone          = k.Phone,
                DirecteurId    = (int)k.DirecteurId,
                nameDir        = userService.GetById((int)k.DirecteurId).email
            };

            return(View(ks));
        }