예제 #1
0
        public async Task <IActionResult> PutPost(int id, Post post)
        {
            if (id != post.Id)
            {
                return(BadRequest());
            }

            _context.Entry(post).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PutPost([FromRoute] Guid id, [FromBody] Post post)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != post.MessageId)
            {
                return(BadRequest());
            }

            _context.Entry(post).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public IHttpActionResult PutPost(Guid id, Post post)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != post.ID)
            {
                return(BadRequest());
            }

            db.Entry(post).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
 public ActionResult Edit([Bind(Include = "AuthorID,FirstName,LastName,AuthorName,Email,CompanyName,CompanyZip,CompanyCity, CompanyState")] Author author)
 {
     if (ModelState.IsValid)
     {
         var myAuthor = db.Authors.Find(author.AuthorID);
         db.Entry(myAuthor).State = EntityState.Detached;
         if (myAuthor.Email != author.Email)
         {
             ModelState.AddModelError("Email", "You cannot change the author email address!");
             return(View(author));
         }
         author.AuthorName      = author.FirstName + " " + author.LastName;
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
예제 #5
0
 public ActionResult Edit([Bind(Include = "ID,PostTitle,PostAuthor,PostTags,PostText,TitlePic,EditDate")] Posts posts)
 {
     if (ModelState.IsValid)
     {
         db.Entry(posts).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(posts));
 }
예제 #6
0
 public ActionResult Edit([Bind(Include = "BlogID,Name")] Blog blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(blog));
 }
예제 #7
0
 public ActionResult Edit([Bind(Include = "ID,PostFK,PicTitle,EditDate,PictPict")] Picts picts)
 {
     if (ModelState.IsValid)
     {
         db.Entry(picts).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(picts));
 }
예제 #8
0
 public ActionResult Edit([Bind(Include = "ID,TagName,CreatedAt")] PostTag postTag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(postTag).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(postTag));
 }
 public ActionResult Edit(PostCategory postCategory)
 {
     if (ModelState.IsValid)
     {
         postCategory.UpdatedBy       = LoggedUserInfo.GetLoggedUserInfo().ID;
         db.Entry(postCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(postCategory));
 }
예제 #10
0
 public ActionResult Edit([Bind(Include = "PostID,Tag,FeaturedImageURL,Title,AuthorID,BlogID,Content,Date")] Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AuthorID = new SelectList(db.Authors, "AuthorID", "FirstName", post.AuthorID);
     ViewBag.BlogID   = new SelectList(db.Blogs, "BlogID", "Name", post.BlogID);
     return(View(post));
 }
예제 #11
0
        public ActionResult Edit([Bind(Include = "ID,PostTitle,PostAuthor,PostTags,PostText,TitlePic,EditDate")] Posts posts)
        {
            if (ModelState.IsValid)
            {
                String aDate = DateTime.UtcNow.ToString("yyMMddHHmmss");
                posts.EditDate = aDate;

                db.Entry(posts).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(posts));
        }