public QRCodeNode(NodeInformation ni) { if (ni == null) return; RoomName = ni.RoomName; DisplayName = ni.DisplayName; if (ni.Node == null) return; NodeId = ni.Node.Id; FloorId = ni.Node.FloorId; }
public static NodeInformation GetNodeInformationForNode(MapsEntities entities, int nodeId) { var result = new NodeInformation(); Nodes node = entities.Nodes.Find(nodeId); if (node == null) throw new ServiceException(ResponseError.NodeIdDoesNotExist); result.Node = Conversions.ToNode(node); Data.Entities.NodeInformation queriedNodeInformation = entities.NodeInformation.FirstOrDefault(x => x.NodeId == nodeId); // Wenn keine Infos hinterlegt sind, dann leere Info zurückgegeben // Wichtig: Das ist kein Fehlerfall if (queriedNodeInformation == null) return result; return Conversions.ToNodeInformation(queriedNodeInformation); }
public ObjectResponse<NodeInformation> SaveNodeInformation(NodeInformation nodeInf) { var result = new ObjectResponse<NodeInformation>(); ExecuteMaps(entities => { result.Object = InformationService.SaveNodeInformation(entities, nodeInf); }, result); return result; }
private static void CreateOrUpdateNodeInfo(MapsEntities entities, NodeInformation inputInfo, Data.Entities.NodeInformation nodeInformation, PoIs poi) { int? poiId = poi != null ? (int?)poi.Id : null; // Wenn es keine NodeInfo gibt, eine Neue anlegen if (nodeInformation == null) { entities.NodeInformation.Add(new Data.Entities.NodeInformation { DisplayName = inputInfo.DisplayName, RoomName = inputInfo.RoomName, QRCode = inputInfo.QRCode, NFCTag = inputInfo.NFCTag, PoiId = poiId, NodeId = inputInfo.Node.Id, CreationTime = DateTime.Now }); } // Ansonsten die bestehende NodeInfo aktualisieren else { nodeInformation.DisplayName = inputInfo.DisplayName; nodeInformation.RoomName = inputInfo.RoomName; nodeInformation.NFCTag = inputInfo.NFCTag; nodeInformation.QRCode = inputInfo.QRCode; nodeInformation.PoiId = poiId; } entities.SaveChanges(); }
public static NodeInformation SaveNodeInformation(MapsEntities entities, NodeInformation inputInfo) { if (!entities.Nodes.Any(n => n.Id == inputInfo.Node.Id)) throw new ServiceException(ResponseError.NodeIdDoesNotExist); // Schon vorhandene Nodeinformationen suchen Data.Entities.NodeInformation nodeInformation = entities.NodeInformation.FirstOrDefault(x => x.NodeId == inputInfo.Node.Id); if (nodeInformation != null) { PoIs poi = CreateOrUpdatePoI(entities, inputInfo.PoI, nodeInformation); CreateOrUpdateNodeInfo(entities, inputInfo, nodeInformation, poi); if (!string.IsNullOrWhiteSpace(inputInfo.DisplayName) || !string.IsNullOrWhiteSpace(inputInfo.RoomName)) StudMapCache.Map(nodeInformation.Nodes.Floors.MapId).Nodes[inputInfo.Node.Id].HasInformation = true; } return GetNodeInformationForNode(entities, inputInfo.Node.Id); }
public JsonResult SaveNodeInformation(int nodeId, string displayName, string roomName, int poiTypeId, string poiDescription, string qrCode, string nfcTag) { var mapsCtrl = new MapsController(); var nodeInf = new NodeInformation(new PoI { Description = poiDescription, Type = new PoiType {Id = poiTypeId} }, displayName, roomName, qrCode, nfcTag) { Node = new Node {Id = nodeId} }; ObjectResponse<NodeInformation> tmp = mapsCtrl.SaveNodeInformation(nodeInf); return Json(tmp, JsonRequestBehavior.AllowGet); }