public async Task <Page> UpdateAsync(UpdatePageCommand cmd) { if (!cmd.IsValid) { throw new InvalidCommandException(nameof(UpdatePageCommand), cmd); } var page = await _unitOfWork.PageRepository.FindAsync(cmd.Id) ?? throw new NotFoundException(nameof(Page), cmd.Id); if (!_auth.CanWrite(page.Book)) { throw new NotAllowedException(_auth.Login, nameof(Page), page.Id); } page.Title = cmd.Title; page.Slug = await GetUniqueSlugAsync(cmd.Slug, page.Book.Id, page.Id); page.Type = cmd.Type; page.State = cmd.State; page.UpdatedAt = DateTime.Now; _unitOfWork.PageRepository.Update(page); await _unitOfWork.SaveAsync(); return(page); }
public bool Update(UpdatePageCommand command) { Page model = _mapper.Map <Page>(command); _pageService.Update(model); return(true); }
public Task UpdateAsync(UpdatePageCommand command) { return(ExtendableContentRepository.ExecuteCommandAsync(command)); }
public async Task UpdatePageAsync(int pageId, UpdatePageCommand command) { await api.PutAsync(GetPagesPath(pageId), command); }
public PageContract(UpdatePageCommand command) { Contract = new ValidationContract() .Requires() .IsGreaterThan(1, 0, "Id", "O campo Id é obrigatório"); }