public async Task Create(MeterReadingDTO dto) { //var flats = await buildingService.GetFlatDTO(dto.FlatId); //var period = await periodService.GetPeriodDTO(dto.PeriodId); Guid id = Guid.NewGuid(); using (MUEContext db = new MUEContext()) { var mr = await GetEntity(dto.FlatId, dto.PeriodId, dto.TypeofServiceId); if (mr != null) { await Delete(mr.MeterReadingId); } MeterReading meterReading = new MeterReading { FlatId = dto.FlatId, MeterReadingId = id, PeriodId = dto.PeriodId, TypeofServiceId = dto.TypeofServiceId, Value = dto.Value, }; db.MeterReadings.Add(meterReading); await db.SaveChangesAsync(); } }
public async Task <ActionResult> SubmitMeterReading(MeterReadingDTO dto) { await meterReadingService.Create(dto); return(RedirectToAction("Index")); }