コード例 #1
0
        public async Task <IHttpActionResult> PutCommentsModal(int id, CommentsModal commentsModal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != commentsModal.CommentId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Surname")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(person));
        }