public ActionResult UpdateNote(int id, NoteUpdateDto noteUpdateDto) { var noteModelFromRepo = _repository.GetNoteByID(id); if (noteModelFromRepo == null) { return(NotFound()); } _mapper.Map(noteUpdateDto, noteModelFromRepo); _repository.UpdateNote(noteModelFromRepo); _repository.SaveChanges(); return(NoContent()); }
public async Task <IHttpActionResult> UpdateNote([FromBody] NoteUpdateDto upNoteDto) { if (upNoteDto == null) { return(BadRequest()); } ApplicationDbContext db = _unitOfWork.GetContext(); WeekPaiment wpai = db.WeekPaiments.Include("WeekOrderMenu").FirstOrDefault(wp => wp.Id == upNoteDto.Id); if (wpai != null) { wpai.Note = upNoteDto.Note; db.Entry(wpai).State = EntityState.Modified; await _unitOfWork.SaveChangesAsync(); } return(Ok(true)); }
public async Task EditNoteAsync(int id, NoteUpdateDto newNote) { Uri uri = new Uri(string.Format(Constants.RestUrl + "{0}", id)); try { string json = JsonConvert.SerializeObject(newNote); StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await _client.PutAsync(uri, content); if (response.IsSuccessStatusCode) { Debug.WriteLine(@"\tNote edited succesfully."); } } catch (Exception ex) { Debug.WriteLine(@"\tERROR: {0}", ex); } }
public async Task <IActionResult> Patch([FromRoute] Guid userId, [FromRoute] Guid noteId, [FromBody] NoteUpdateDto noteUpdateDto) { throw new NotImplementedException(); }
public Task UpdateNoteAsync(int id, NoteUpdateDto note) { return(_restService.EditNoteAsync(id, note)); }