Пример #1
0
 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
        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
 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));
        }
        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());
        }
        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());
 }