Ejemplo n.º 1
0
        public ActionResult Create(PostViewModel pvm, CategoryPostViewModel id)
        {
            var c = Ps.GetAll();

            foreach (var item in c)
            {
                CategoryPostViewModel Cvm = new CategoryPostViewModel();
                Cvm.categorypostId = item.categorypostId;
                Cvm.nom            = item.nom;

                /*Cvm.categoryId = item.categoryId;
                 * Cvm.description = item.description;
                 * Cvm.plan = item.plan;
                 * Cvm.goals = item.goals;
                 * Cvm.state = (WebApplication1.Models.stat)stat.To_Do;*/
            }

            // ViewBag.cat = new SelectList(c, "projectId", "projectname");

            Post p = new Post();

            p.postId = pvm.postId;
            //p.categoriepostId=id.categorypostId;
            p.categorypostId = id.categorypostId;
            p.post_like      = pvm.post_like;
            p.posttitre      = pvm.posttitre;
            p.content        = pvm.content;
            p.datepost       = DateTime.Now;



            //// p.catgoriepostId = id.categorypostId;
            // p.content = pvm.content;
            // //p.userId = 1;
            //// p.user.Id = pvm.user.Id;
            Ts.Add(p);
            Ts.Commit();
            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction("listepost"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        // GET: Post/Create
        public ActionResult Create()
        {
            var c = Ps.GetAll();

            foreach (var item in c)
            {
                CategoryPostViewModel Cvm = new CategoryPostViewModel();
                //  Cvm.catgoriepostId = item.catgoriepostId;
                Cvm.categorypostId = item.categorypostId;
                Cvm.nom            = item.nom;


                /*  Cvm.categoryId = item.categoryId;
                 * Cvm.description = item.description;
                 * Cvm.plan = item.plan;
                 * Cvm.goals = item.goals;
                 * Cvm.state = (WebApplication1.Models.stat)stat.To_Do;*/
            }


            ViewBag.cat = new SelectList(c, "categorypostId", "nom");
            return(View());
        }