// Add or update station entity public GL_StationDTO AddOrUpdateStation(GL_StationDTO dto, out string errorMessage) { errorMessage = string.Empty; GL_Station entity = AutoMapper.Mapper.Map <GL_Station>(dto); if (entity.IsBirth == true || entity.IsOutput == true) { var entities = _stationRepository.GetMany(x => x.LineID == entity.LineID); if (entity.IsBirth == true) { foreach (var e in entities) { e.IsBirth = false; } } if (entity.IsOutput == true) { foreach (var e in entities) { e.IsOutput = false; } } } try { GL_Station entityContext; if (dto.StationID == 0) { entity.MESStationName = entity.MESStationName ?? ""; entityContext = _stationRepository.Add(entity); _unitOfWork.Commit(); } else { entityContext = _stationRepository.GetById(entity.StationID); entityContext.Seq = entity.Seq; entityContext.StationName = entity.StationName; entityContext.MESStationName = entity.MESStationName ?? ""; entityContext.CycleTime = entity.CycleTime; entityContext.IsBirth = entity.IsBirth; entityContext.IsOutput = entity.IsOutput; entityContext.IsTest = entity.IsTest; entityContext.Modified_UID = entity.Modified_UID; entityContext.Modified_Date = entity.Modified_Date; entityContext.IsEnabled = entity.IsEnabled; entityContext.DashboardTarget = entity.DashboardTarget; _stationRepository.Update(entityContext); _unitOfWork.Commit(); } var returnDto = AutoMapper.Mapper.Map <GL_StationDTO>(entityContext); return(returnDto); } catch (Exception ex) { errorMessage = ex.Message; return(null); } }
public GL_QADetectionPointDTO GetStationsDetectionPointByID(int StationID) { GL_Station Station = _stationRepository.GetById(StationID); GL_QADetectionPointDTO qADetectionPointDTO = new GL_QADetectionPointDTO(); var gGL_QADetectionPointDTO = gL_QADetectionPointRepository.GetStationsDetectionPointByID(StationID); if (gGL_QADetectionPointDTO != null) { qADetectionPointDTO = gGL_QADetectionPointDTO; } else { qADetectionPointDTO.StationID = Station.StationID; qADetectionPointDTO.StationName = Station.StationName; qADetectionPointDTO.MESStationName = Station.MESStationName; } return(qADetectionPointDTO); }