public IActionResult UpdateIncome([FromBody] UpdateIncomeDto dto) { var income = this._context.Incomes.Find(dto.Id); income = _mapper.Map <UpdateIncomeDto, Income>(dto, income); this._context.Update(income); this._context.SaveChanges(); return(Ok(income)); }
public async Task <IActionResult> UpdateIncome([FromBody] UpdateIncomeDto updateIncomeDto) { var user = await _userService.GetById(int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier))); if (updateIncomeDto.PlannerId != user.PlannerId) { return(BadRequest()); } await _incomeService.Update(updateIncomeDto); return(Ok()); }
public async Task <bool> UpdateIncomeAsync(int incomeId, UpdateIncomeRequest request) { var incomeDto = new UpdateIncomeDto { Id = incomeId, Name = request.Name, Description = request.Description, IncomeDate = request.IncomeDate, IncomeValue = request.IncomeValue, CurrencyId = request.CurrencyId, PeriodId = request.PeriodId }; var income = _mapper.Map <Income>(incomeDto); return(await _baseRepository.UpdateEntityAsync(income)); }