public async Task <IActionResult> Update([FromBody] QuotaContract contract) { try { var quota = contract.Quota; var quotaForUpdate = await _quotaRepository.FindByIdAsync(quota.Id); if (quotaForUpdate == null) { return(BadRequest("Item not found")); } var curentUser = await _userManager.FindByEmailAsync(HttpContext.User.Identity.Name); quotaForUpdate.ClientId = curentUser.Id; quotaForUpdate.AdditionalContributions = quota.AdditionalContributions; quotaForUpdate.CityId = quota.CityId; quotaForUpdate.Comment = quota.Comment; quotaForUpdate.CreatedAt = quota.CreatedAt; quotaForUpdate.InterestRate = quota.InterestRate; quotaForUpdate.ModifiedAt = quota.ModifiedAt; quotaForUpdate.RefinancingAmount = quota.RefinancingAmount; quotaForUpdate.RefinancingTarget = quota.RefinancingTarget; await _quotaRepository.UpdateAsync(quotaForUpdate); return(Ok()); } catch (Exception exception) { return(BadRequest(exception.Message)); } }
public async Task <IActionResult> Create([FromBody] QuotaContract contract) { try { var quota = contract.Quota; var curentUser = await _userManager.FindByEmailAsync(HttpContext.User.Identity.Name); quota.ClientId = curentUser.Id; await _quotaRepository.CreateAsync(quota); return(Ok(quota.Id)); } catch (Exception exception) { return(BadRequest(exception.Message)); } }