Example #1
0
        public ActionResult Edit([Bind(Include = "Id,UserId,Title,Text,Price")] Project project, HttpPostedFileBase File)
        {
            if (ModelState.IsValid)
            {
                db.Entry(project).State = EntityState.Modified;

                if (File != null && File.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(File.InputStream))
                    {
                        project.File        = reader.ReadBytes(File.ContentLength);
                        project.ContentType = File.ContentType;
                    }
                }
                else
                {
                    db.Entry(project).Property("File").IsModified        = false;
                    db.Entry(project).Property("ContentType").IsModified = false;
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.UserId = new SelectList(db.UserSet, "Id", "Name", project.UserId);
            return(View(project));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "Id,Title,Slug")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Example #3
0
 public ActionResult Edit([Bind(Include = "Id,Title")] UserType userType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userType));
 }
Example #4
0
 public ActionResult Edit([Bind(Include = "Id,UserId,Amount,Date")] Payment payment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.UserSet, "Id", "Name", payment.UserId);
     return(View(payment));
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "Id,UserId,CategoryId,Title,Text,Date")] Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId     = new SelectList(db.UserSet, "Id", "Name", post.UserId);
     ViewBag.CategoryId = new SelectList(db.CategorySet, "Id", "Title", post.CategoryId);
     return(View(post));
 }
Example #6
0
 public ActionResult Edit([Bind(Include = "Id,PostId,UserId,Text,Date,Verified")] Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PostId = new SelectList(db.PostSet, "Id", "Title", comment.PostId);
     ViewBag.UserId = new SelectList(db.UserSet, "Id", "Name", comment.UserId);
     return(View(comment));
 }
 public ActionResult Edit([Bind(Include = "Id,ProjectId,UserId")] ProjectAccess projectAccess)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projectAccess).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProjectId = new SelectList(db.ProjectSet, "Id", "Title", projectAccess.ProjectId);
     ViewBag.UserId    = new SelectList(db.UserSet, "Id", "Name", projectAccess.UserId);
     ViewBag.Id        = new SelectList(db.PaymentSet, "Id", "Id", projectAccess.Id);
     return(View(projectAccess));
 }
Example #8
0
        public ActionResult Edit([Bind(Include = "Id,UserTypeId,Name,Mail,Password")] User user, HttpPostedFileBase Avatar)
        {
            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;

                if (Avatar != null && Avatar.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(Avatar.InputStream))
                    {
                        user.Avatar = reader.ReadBytes(Avatar.ContentLength);
                    }
                }
                else
                {
                    db.Entry(user).Property("Avatar").IsModified = false;
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.UserTypeId = new SelectList(db.UserTypeSet, "Id", "Title", user.UserTypeId);
            return(View(user));
        }