public async Task <IActionResult> CreateRecord(MoneyChangeRecord moneyChange) { if (null == moneyChange.Date) { moneyChange.Date = DateTime.Now; } await _unitOfWork.MoneyChangeRecords.AddAsync(moneyChange); await _unitOfWork.SaveChangesAsync(); return(Ok(moneyChange)); }
public async Task <IActionResult> UpdateRecord(int id, MoneyChangeRecord moneyChange) { var dbRecord = await _unitOfWork.MoneyChangeRecords.GetAsync(id); if (dbRecord == null) { return(NotFound(moneyChange)); } ; dbRecord.Amount = moneyChange.Amount; dbRecord.Date = moneyChange.Date; dbRecord.MoneyChangeTypeId = moneyChange.MoneyChangeTypeId; dbRecord.UserId = moneyChange.UserId; await _unitOfWork.SaveChangesAsync(); return(Ok(dbRecord)); }