Пример #1
0
 // Mappers
 private static WaterStatementDTO ItemToDTO(WaterStatement waterStatement) => new WaterStatementDTO
 {
     Id          = waterStatement.Id,
     HouseholdId = waterStatement.HouseholdId,
     Date        = waterStatement.Date,
     Amount      = waterStatement.Amount,
     Paid        = waterStatement.Paid,
 };
Пример #2
0
        public async Task <ActionResult <WaterStatementDTO> > PostWaterStatement(WaterStatementDTO waterStatementDto)
        {
            var waterStatement = new WaterStatement
            {
                HouseholdId = waterStatementDto.HouseholdId,
                Date        = waterStatementDto.Date,
                Amount      = waterStatementDto.Amount,
                Paid        = waterStatementDto.Paid,
            };

            _context.WaterStatement.Add(waterStatement);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(
                       nameof(GetWaterStatement),
                       new { id = waterStatement.Id },
                       ItemToDTO(waterStatement)));
        }