コード例 #1
0
ファイル: NoteRepository.cs プロジェクト: lisi8866/eftest
 public Task UpdateAsync(Note note)
 {
     context.Entry(note).State = EntityState.Modified;
     //context.Entry(note).State = EntityState.Deleted;
     //  context.Update(note);
     return(context.SaveChangesAsync());
 }
コード例 #2
0
        public async Task <IActionResult> PutNote(long id, Note note)
        {
            if (id != note.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #3
0
ファイル: CatApiController.cs プロジェクト: kansasm/NoteApp
        public async Task <IActionResult> PutCategory([FromRoute] int id, [FromBody] Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
コード例 #4
0
        public IHttpActionResult PutNote(int id, Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != note.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
        public ActionResult EditNote(Note note)
        {
            Note SelectedNote = db.Notes.Find(note.Id);

            if (SelectedNote == null || note == null)
            {
                return(HttpNotFound());
            }
            SelectedNote.Description     = note.Description;
            SelectedNote.Done            = note.Done;
            SelectedNote.Priority        = note.Priority;
            SelectedNote.CreationTime    = note.CreationTime;
            db.Entry(SelectedNote).State = EntityState.Modified;
            db.SaveChanges();
            return(new HttpStatusCodeResult(200));
        }
コード例 #6
0
        public async Task <IActionResult> PutNote([FromRoute] int id, [FromBody] Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != note.NoteId)
            {
                return(BadRequest());
            }

            note.UpdatedOn = DateTime.Now;

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

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

            return(CreatedAtAction("GetNote", new { id = note.NoteId }, note));
        }
コード例 #7
0
ファイル: NotesController.cs プロジェクト: marioskan/NoteMe
 public ActionResult Edit([Bind(Include = "ID,Name,Note,Date")] Notes notes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(notes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(notes));
 }
コード例 #8
0
        public ActionResult Edit(Note note)
        {
            Note oldNote = db.Notes.Find(note.Id);

            oldNote.Title           = note.Title;
            oldNote.Message         = note.Message;
            oldNote.Time            = DateTime.Now;
            db.Entry(oldNote).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Personal"));
        }
コード例 #9
0
        public async Task <ActionResult> Edit([Bind(Include = "NoteId,NoteDescription,HaveDone")] Note note)
        {
            if (ModelState.IsValid)
            {
                db.Entry(note).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(note));
        }
コード例 #10
0
        public async Task <IActionResult> PutNote(int id, Note note)
        {
            if (id != note.Id)
            {
                return(BadRequest());
            }

            _context.Entry(note).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #11
0
        public IHttpActionResult PutNotes(int id, Note note)
        {
            if (db.Notes.Count(e => e.Id == id) == 0)
            {
                return(NotFound());
            }

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #12
0
        public async Task <IActionResult> PutNoteItem(long id, NoteItem item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #13
0
        public ActionResult PutNoteItem(int id, Note note)
        {
            if (id != note.Id)
            {
                return(BadRequest());
            }

            _context.Entry(note).State = EntityState.Modified;
            _context.SaveChanges();

            return(NoContent());
        }
コード例 #14
0
        public async Task <IActionResult> PutNotes([FromRoute] int id, [FromBody] Note notes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != notes.ID)
            {
                return(BadRequest());
            }
            var user     = _context.Users.Find(notes.User.ID);
            var category = _context.Categories.Find(notes.Category.ID);

            notes.User     = user;
            notes.Category = category;

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

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

            return(NoContent());
        }
コード例 #15
0
 public void Update(T item)
 {
     item.UpdateDate           = DateTime.Now;
     context.Entry(item).State = EntityState.Modified;
 }
コード例 #16
0
 public Task UpdateAsync(Note note)
 {
     _context.Entry(note).State = EntityState.Modified;
     return(_context.SaveChangesAsync());
 }