public async Task Execute(UpdateNoteInput input) { var note = await context.Notes.SingleOrDefaultAsync(x => x.Id == input.Id); if (note == null) { outputPort.WriteError("Not Found this note"); return; } if (note.UserId != currentUser.UserId) { outputPort.Standart(new UpdateNoteOutput(false)); return; } if (input.Title.Length < 2) { outputPort.WriteError("Title length must be more than 1 character"); return; } if (input.Text.Length > 300) { outputPort.WriteError("Text length must be less than 300 characters"); return; } note.Title = input.Title; note.Text = input.Text; await context.SaveChangesAsync(new System.Threading.CancellationToken()); outputPort.Standart(new UpdateNoteOutput(true)); }
public async Task <Payload <BookRecommedation> > UpdateNoteAsync( UpdateNoteInput input, [ScopedService] BookRefDbContext context, [Service] IGetClaimsProvider claimsProvider) { var library = context.Libraries.First(e => e.Id == claimsProvider.LibraryId); var recommedation = library.UpdateRecommendationNote(input.noteId, input.content); await context.SaveChangesAsync(); return(new Payload <BookRecommedation>(recommedation)); }