Esempio n. 1
0
        public ActionResult <Note> Edit([FromBody] NoteDtoEdit model)
        {
            var result = _notesRepository.Edit(model);

            if (result == null)
            {
                BadRequest();
            }

            return(Ok(result));
        }
        public ActionResult <Note> Edit([FromBody] NoteDtoEdit model)
        {
            Note oldNote = StaticDB.Notes.FirstOrDefault(n => n.Id == model.Id);

            if (oldNote == null)
            {
                return(this.NotFound($"Note with {model.Id} was not found!"));
            }

            oldNote.Title       = !string.IsNullOrWhiteSpace(model.Title) ? model.Title : oldNote.Title;
            oldNote.Description = !string.IsNullOrWhiteSpace(model.Description) ? model.Description : oldNote.Description;
            oldNote.DueDate     = !(model.DueDate == null) ? model.DueDate : oldNote.DueDate;

            return(Ok(oldNote));
        }
Esempio n. 3
0
        public Note Edit(NoteDtoEdit model)
        {
            Note note = StaticDB.Notes.FirstOrDefault(n => n.Id == model.Id);

            try
            {
                note.Title       = !string.IsNullOrWhiteSpace(model.Title) ? model.Title : note.Title;
                note.Description = !string.IsNullOrWhiteSpace(model.Description) ? model.Description : note.Description;
                note.DueDate     = !(model.DueDate == null) ? model.DueDate : note.DueDate;
                return(note);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 4
0
        public Note Edit(NoteDtoEdit model)
        {
            var result = _dataDbContext.Notes.FirstOrDefault(x => x.Id == model.Id);

            if (result == null)
            {
                return(null);
            }

            result.Title       = model.Title;
            result.Description = model.Description;
            result.DueDate     = model.DueDate;

            _dataDbContext.Notes.Update(result);
            _dataDbContext.SaveChanges();

            return(result);
        }
 public Note Edit(NoteDtoEdit model) => _notesRepository.Edit(model);
 public Note Edit(NoteDtoEdit model)
 {
     throw new NotImplementedException();
 }