public IResponse Execute(string payload)
        {
            JObject json = JsonConvert.DeserializeObject<JObject>(payload);
            string name = json[NameKey].ToString();

            RoadplusData data = new RoadplusData();

            Zone newZone = new Zone()
            {
                Name = name,
                StartVertexId = 0,
                RadarVertexId = 0
            };

            int newZoneId = Convert.ToInt32(
                data.InsertWithIdentity<Zone>(newZone));

            Vertex startVertex = new Vertex()
            {
                X = 0,
                Y = 0,
                ZoneId = newZoneId
            };

            int startVertexId = Convert.ToInt32(
                data.InsertWithIdentity<Vertex>(startVertex));

            newZone.ZoneId = newZoneId;
            newZone.StartVertexId = startVertexId;

            data.Update<Zone>(newZone);
            
            CreateResponse response = new CreateResponse()
            {
                Command = Name,
                CreatedObject = newZone
            };

            return response;
        }
        public IResponse Execute(string payload)
        {
            JObject o = JsonConvert.DeserializeObject<JObject>(payload);

            int zoneId;
            int locationId;
            DateTime startDate = DateTime.ParseExact(
                                     o[StartDateKey].ToString(),
                                     "yyyy-MM-dd",
                                     CultureInfo.InvariantCulture);
            DateTime endDate = DateTime.ParseExact(
                                   o[EndDateKey].ToString(), 
                                   "yyyy-MM-dd",
                                   CultureInfo.InvariantCulture);

            if (!Int32.TryParse(o[ZoneIdKey].ToString(), out zoneId) ||
                !Int32.TryParse(o[LocationKey].ToString(), out locationId))
            {
                return new ResponseFailure(Name, "Parse error");
            }

            RoadplusData data = new RoadplusData();

            if (!data.Zones.Any(z => z.ZoneId == zoneId))
            {
                return new ResponseFailure(Name, "Zone does not exist");
            }
            else if (!data.Edges.Any(e => e.EdgeId == locationId))
            {
                return new ResponseFailure(Name, "Edge does not exist");
            }

            RoadConstruction newRC = new RoadConstruction()
            {
                    Name = o[NameKey].ToString(),
                    ZoneId = zoneId,
                    EdgeId = locationId,
                    DateStart = startDate,
                    DateEnd = endDate
            };

            int id = Convert.ToInt32(
                data.InsertWithIdentity<RoadConstruction>(newRC));

            newRC.RoadConstructionId = id;

            return new CreateResponse()
            {
                Command = Name,
                CreatedObject = newRC
            };
        }
        public IResponse Execute(string payload)
        {
            JObject o = JsonConvert.DeserializeObject<JObject>(payload);

            int zoneId;
            int locationId;
            DateTime openTime;
            DateTime closeTime;

            if (!Int32.TryParse(o[ZoneIdKey].ToString(), out zoneId) ||
                !Int32.TryParse(o[LocationKey].ToString(), out locationId) ||
                !DateTime.TryParseExact(
                    o[OpenTimeKey].ToString(), "HH:mm", CultureInfo.InvariantCulture, 
                    DateTimeStyles.None, out openTime) ||
                !DateTime.TryParseExact(
                    o[CloseTimekey].ToString(), "HH:mm", CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out closeTime))
            {
                return new ResponseFailure(Name, "Parse error");
            }

            RoadplusData data = new RoadplusData();

            if (!data.Vertices.Any(v => v.VertexId == locationId) ||
                !data.Zones.Any(z => z.ZoneId == zoneId))
            {
                return new ResponseFailure(Name, "Nonexisting parent");
            }

            School newSchool = new School()
            {
                Name = o[NameKey].ToString(),
                ZoneId = zoneId,
                VertexId = locationId,
                OpenTime = openTime,
                CloseTime = closeTime
            };

            int id = Convert.ToInt32(
                data.InsertWithIdentity<School>(newSchool));

            newSchool.SchoolId = id;

            return new CreateResponse()
            {
                Command = Name,
                CreatedObject = newSchool
            };
        }
        public IResponse Execute(string payload)
        {
            JObject o = JsonConvert.DeserializeObject<JObject>(payload);

            int zoneId, startVertexX, startVertexY, endVertexX, endVertexY;

            if (!Int32.TryParse(o[ZoneIdKey].ToString(), out zoneId) ||
                !Int32.TryParse(o[startVertexXKey].ToString(), out startVertexX) ||
                !Int32.TryParse(o[startVertexYKey].ToString(), out startVertexY) ||
                !Int32.TryParse(o[endVertexXKey].ToString(), out endVertexX) ||
                !Int32.TryParse(o[endVertexYKey].ToString(), out endVertexY))
            {
                return new ResponseFailure(
                    Name,
                    "Int32 Parse error");
            }

            RoadplusData data = new RoadplusData();

            if (!data.Zones.Any(z => z.ZoneId == zoneId))
            {
                return new ResponseFailure(
                    Name,
                    "Zone does not exist");
            }

            Vertex startVertex = new Vertex()
            {
                    ZoneId = zoneId,
                    X = startVertexX,
                    Y = startVertexY
            };
            
            Vertex endVertex = new Vertex()
            {
                    ZoneId = zoneId,
                    X = endVertexX,
                    Y = endVertexY
            };

            int startVertexId = Convert.ToInt32(
                data.InsertWithIdentity<Vertex>(startVertex));

            int endVertexId = Convert.ToInt32(
                data.InsertWithIdentity<Vertex>(endVertex));

            startVertex.VertexId = startVertexId;
            endVertex.VertexId = endVertexId;

            Edge newEdge = new Edge()
            {
                    ZoneId = zoneId,
                    StartVertexId = startVertexId,
                    EndVertexId = endVertexId,
                    Weight = 0.0,
                    MaxSpeed = 0
            };

            int edgeId = Convert.ToInt32(
                data.InsertWithIdentity<Edge>(newEdge));

            newEdge.EdgeId = edgeId;

            return new EdgeSetResponse()
            {
                ZoneId = zoneId,
                CreatedEdge = newEdge,
                StartVertex = startVertex,
                EndVertex = endVertex
            };
        }