public async Task PutGrudgeAsync(GrudgeModel grudge) { var getRepository = _unitOfWork.GetRepository <GrudgeModel>(); var entity = _mapper.Map <GrudgeModel>(grudge); getRepository.Update(entity); await _unitOfWork.CommitAsync(); }
public async Task PostGrudgeAsync(GrudgeModel grudge) { var getRepository = _unitOfWork.GetRepository <GrudgeModel>(); grudge.Date = DateTime.Now; var entity = _mapper.Map <GrudgeModel>(grudge); getRepository.Add(entity); await _unitOfWork.CommitAsync(); }
public async Task <IActionResult> PostGrudges(GrudgeModel grudge) { try { await _grudgeApi.PutGrudgeAsync(grudge); return(Ok()); } catch { return(BadRequest()); } }
public async Task <ActionResult <GrudgeModel> > PostGrudgeAsync(GrudgeModel grudge) { try { await _grudgesApi.PostGrudgeAsync(grudge); } catch (Exception e) { Console.WriteLine(e); throw; } return(Ok()); }
public async Task <IActionResult> PutGrudgeAsync(GrudgeModel grudge) { if (grudge.Id != 0) //todo настроить нормально обработку ошибок { return(BadRequest()); } try { await _grudgesApi.PutGrudgeAsync(grudge); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(NoContent()); }