Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "PostId,Title,Text,Image,UserId,Date")] Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "UserId", "LastName", post.UserId);
     return(View(post));
 }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "VolonteerId,UserId,FirstName,Email,Message")] Volonteer volonteer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(volonteer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(volonteer));
 }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "QuestionId,UserId,FirstName,Email,Title,Message")] Question question)
 {
     if (ModelState.IsValid)
     {
         db.Entry(question).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(question));
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "UserId,LastName,FirstName,Email,LoginId,Image,last_name,RoleId")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.LoginId = new SelectList(db.Logins, "Id", "UserLogin", user.LoginId);
     ViewBag.RoleId  = new SelectList(db.Roles, "Id", "RoleName", user.RoleId);
     return(View(user));
 }
Ejemplo n.º 5
0
 public ActionResult Edit(NeedHelpUser needHelpUser)
 {
     if (ModelState.IsValid)
     {
         //using (var binaryReader = new BinaryReader(uploadImage.InputStream))
         //{
         //    Random r = new Random();
         //    string fileName = $"/Content/images/{r.Next()}{uploadImage.FileName}";
         //    string savePath = $"{Request.PhysicalApplicationPath}{fileName}";
         //    System.IO.File.WriteAllBytes(savePath, binaryReader.ReadBytes(uploadImage.ContentLength));
         //    needHelpUser.Image = fileName;
         //}
         needHelpUser.Image           = (string)this.Session["Image"];
         needHelpUser.UserId          = (int)this.Session["CurrentUser"];
         needHelpUser.Date            = DateTime.Now;
         db.Entry(needHelpUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { id = this.Session["CurrentUser"] }));
     }
     ViewBag.UserId = new SelectList(db.Users, "UserId", "LastName", needHelpUser.UserId);
     return(View(needHelpUser));
 }
Ejemplo n.º 6
0
        public ActionResult EditUser(User user, string Password)
        {
            user.Login.Password = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(
                System.Text.Encoding.Unicode.GetBytes(Password));

            db.Entry(user.Login).State = EntityState.Modified;
            db.Entry(user).State       = EntityState.Modified;
            db.SaveChanges();


            int UserIdFromDb = user.UserId;

            this.Session.Add("CurrentUser", user.UserId);
            this.Session.Add("CurrentUserPassword", Password);



            return(RedirectToAction("PersonalCabinet"));

            ViewBag.UserId = new SelectList(db.Users, "UserId", "LastName", user.FirstName, user.LastName, user.Image);
            return(View("PersonalCabinet"));
        }