public async Task <AphorismDto> AddAphorismAsync(AphorismDto aphorismDto) { var aphorism = _mapper.Map <Aphorism>(aphorismDto); _aphorismRepository.Add(aphorism); await _aphorismRepository.SaveChangesAsync(); return(_mapper.Map <AphorismDto>(aphorism)); }
public async Task <bool> UpdateAphorismAsync(AphorismDto aphorismDto) { var aphorism = _mapper.Map <Aphorism>(aphorismDto); _aphorismRepository.Update(aphorism); var affectedRows = await _aphorismRepository.SaveChangesAsync(); return(affectedRows > 0); }
public async Task <IActionResult> PutAphorismAsync(AphorismDto aphorismDto) { var updated = await _aphorismService.UpdateAphorismAsync(aphorismDto); if (!updated) { return(NotFound()); } return(NoContent()); }
public async Task <bool> SaveProduct(AphorismDto aphorismDto) { await _context.Aphorisms.AddAsync(new Aphorism() { Id = Guid.NewGuid(), CreationDate = DateTime.UtcNow, UpdateDate = DateTime.UtcNow, Value = aphorismDto.Value }); return(await _context.SaveChangesAsync() > 0); }
public async Task <ActionResult <AphorismDto> > PostAphorismAsync([FromBody] AphorismDto aphorismDto) { var insertedAphorism = await _aphorismService.AddAphorismAsync(aphorismDto); return(Created("GetAphorism", insertedAphorism)); }