Beispiel #1
0
        public async Task <NotesDto> EditNotes(int id, EditNoteDto editNoteDto)
        {
            var notes = await _unitOfWork.NotesRepository.GetById(id);

            if (notes == null)
            {
                throw new Exception("Not Found... ");
            }
            var note = _mapper.Map(editNoteDto, notes);

            _unitOfWork.NotesRepository.Update(note);
            await _unitOfWork.CompleteAsync();

            return(_mapper.Map <Notes, NotesDto>(note));
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(int id, EditNoteDto noteDto)
        {
            var stringContent = new StringContent(JsonConvert.SerializeObject(noteDto), Encoding.Unicode,
                                                  "application/json");
            var reponse =
                await SecuredNotesClient.PutAsync(string.Format("api/notes/{0}", id), stringContent).ConfigureAwait(false);


            if (reponse.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(View("Error",
                        new HandleErrorInfo(ExceptionHelper.GetExceptionFromResponse(reponse),
                                            "Notes", "Index")));
        }
 public async Task <IActionResult> UpdateFolders(int id, [FromForm] EditNoteDto editNoteDto) => Ok(await _notesService.EditNotes(id, editNoteDto));