public int SaveOrUpdate(DataParameterDTO dataParameterDTO) { var dataParameter = dataParameterDTO.Id == 0 ? new DataParameter() : _dataParameterRepository.Get(dataParameterDTO.Id); dataParameter.ControlObject = new ControlObject { Id = dataParameterDTO.ControlObject.Id }; dataParameter.MeteringType = dataParameterDTO.MeteringType; dataParameter.Name = dataParameterDTO.Name; dataParameter.Value = dataParameterDTO.Value; dataParameter.LastUpdate = DateTime.Now; _fullDataParameterRepository.SaveOrUpdate(new FullDataParameter { Id=0, ControlObject = new ControlObject { Id = dataParameter.ControlObject.Id }, Name = dataParameter.Name, Value = dataParameter.Value, LastUpdate = DateTime.Now }); return _dataParameterRepository.SaveOrUpdate(dataParameter); }
public DataParameterDTO GetDataParameterDTOById(int id) { var dataParameter = _dataParameterRepository.Get(id); var contrObj = _controlObjectRepository.Get(dataParameter.ControlObject.Id); var dataParameterDTO = new DataParameterDTO { Id = dataParameter.Id, MeteringType = dataParameter.MeteringType, Name = dataParameter.Name, Value = dataParameter.Value, LastUpdate = dataParameter.LastUpdate.ToString(CultureInfo.InvariantCulture), ControlObject = new ControlObjectDTO { Client = new ClientDTO(), DataParameters = new List<DataParameterDTO>(), Discription = contrObj.Discription, Id = contrObj.Id, Name = contrObj.Name } }; return dataParameterDTO; }