public ActionResult Post([FromBody] ElectricityReading bodyER) { var serviceResult = _electricityReadingService.AddElectricityReading(bodyER); if (serviceResult.ResponseCode != ResponseCode.Success) { return(BadRequest(serviceResult.Error)); } var result = new ElectricityReading { Id = serviceResult.Result.Id, KiloWatt = serviceResult.Result.KiloWatt, Panel = serviceResult.Result.Panel, PanelId = serviceResult.Result.PanelId, ReadingDateTime = serviceResult.Result.ReadingDateTime }; return(Ok(result)); }
public ServiceResult <ElectricityReading> AddElectricityReading(ElectricityReading ER) { ER.ReadingDateTime = DateTime.UtcNow; if (ER.KiloWatt < 0) { return ServiceResult <ElectricityReading> .ErrorResult("No se aceptan vlaores menores a 0") } ; if (ER.Panel.MeasuringUnit.Equals("Watt")) { ER.KiloWatt = ER.KiloWatt / 1000; } ; //if (ER.Panel.PanelType == ) //{ } return(ServiceResult <ElectricityReading> .SuccessResult(_electricityReadingService.AddElectricityReading(ER))); } }