예제 #1
0
        // GET: Messages/Details/5
        public ActionResult Details(int?id, string path, int?page)
        {
            //Retiens l'url d'ou l'utilisateur arrive pour un 'Back to List' plus dynamique
            ViewBag.OldUrl = path;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Message message = db.Messages.Find(id);

            if (message == null)
            {
                return(HttpNotFound());
            }
            else
            {
                message.View++;

                db.Entry(message).State = EntityState.Modified;
                db.SaveChanges();

                return(View(new PostDisplay
                {
                    MsgID = message.MsgID,
                    MsgTitle = message.MsgTitle,
                    Views = message.View,
                    MsgText = message.MsgText,
                    CatID = message.CatID,
                    CategoryName = message.Category.CategoryName,
                    User = message.AspNetUser.UserName,
                    UserID = message.AspNetUser.Id,
                    CreationDate = message.CreationDate,
                    IsActive = message.IsActive,
                    RepliesList = db.Reponses
                                  .Where(r => r.MsgID == message.MsgID)
                                  .OrderBy(r => r.CreationDate)
                                  .ToPagedList(page ?? 1, 8) as PagedList <Reponse>
                }));
            }
        }
예제 #2
0
        public ActionResult Edit([Bind(Include = "CatID,CategoryName,IsActive,CreationDate,User")]
                                 Category category)
        {
            if (ModelState.IsValid)
            {
                db.Entry(category).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.User = new SelectList(db.AspNetUsers, "Id", "Email", category.UserID);
            return(View(category));
        }
예제 #3
0
        public ActionResult Edit([Bind(Include =
                                           "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")]
                                 AspNetUser aspNetUser)
        {
            if (ModelState.IsValid)
            {
                db.Entry(aspNetUser).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetUser));
        }