// GET api/<controller>
        public IEnumerable <ActiviteVM> Get()
        {
            //var t = activiteService.GetMany();
            var Activites = new List <ActiviteVM>();

            foreach (Activite p in activiteService.GetMany())
            {
                //if (p.Description.Length > 37)
                //    p.Description = p.Description.Substring(0, 34) + "...";
                Activites.Add(new ActiviteVM()
                {
                    ActiviteID  = p.ActiviteID,
                    Title       = p.Title,
                    Description = p.Description,
                    Affiche     = p.Affiche,
                    Document    = p.Document,
                    Theme       = p.Theme,
                    Outils      = p.Outils,
                    AgeMin      = p.AgeMin,
                    AgeMax      = p.AgeMax,
                    ClassSize   = p.ClassSize,
                    Duration    = p.Duration,
                    Professor   = p.Professor,
                    Start       = p.Start,
                    Location    = p.Location,
                    //    nomuser = User.Identity.GetUserName(),
                    UserId = "f43c21cf-f35a-4897-a9e3-343c00afe7b3"
                });
            }
            return(Activites.ToList());
        }
Exemplo n.º 2
0
        // GET: Activite/Details/5
        public ActionResult Details(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Activite A;

            A = activiteService.GetById((int)id);
            if (A == null)
            {
                return(HttpNotFound());
            }
            ActiviteVM pvm = new ActiviteVM()
            {
                ActiviteID  = A.ActiviteID,
                Title       = A.Title,
                Description = A.Description,
                Affiche     = A.Affiche,
                Document    = A.Document,
                Theme       = A.Theme,
                Outils      = A.Outils,
                AgeMin      = A.AgeMin,
                AgeMax      = A.AgeMax,
                ClassSize   = A.ClassSize,
                Duration    = A.Duration,
                Professor   = A.Professor,
                Start       = A.Start,
                Location    = A.Location,
                //    nomuser = User.Identity.GetUserName(),
                UserId = "f43c21cf-f35a-4897-a9e3-343c00afe7b3"
            };
            var t = activiteService.GetMany();

            foreach (Activite Act in t)
            {
                var         path1 = Path.Combine(Server.MapPath("~/Content/Uploads"), Act.Affiche);
                KalikoImage image = new KalikoImage(path1);
                KalikoImage thumb = image.Scale(new CropScaling(90, 80));
                var         path2 = Path.Combine(Server.MapPath("~/Content/Uploads"), Act.Title + "latest.jpg");
                thumb.SaveJpg(path2, 99);
            }
            List <Activite> Courses = t.ToList();

            ViewData["Courses"] = Courses;
            return(View(pvm));
        }