示例#1
0
        public void VerifyTransportVertexModelRequiredAnnotations()
        {
            var vertexForValidation = new TransportVertex
            {
                Description = "TestDescr"
            };
            var errorCount = CheckPropertyValidation.Validate(vertexForValidation).Count;

            Assert.AreEqual(ClassValidationError, errorCount);
        }
示例#2
0
        public async Task <IActionResult> Create(TransportVertex node)
        {
            if (ModelState.IsValid)
            {
                db.Add(node);
                await db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(node));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, TransportVertex node)
        {
            if (id != node.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                db.Update(node);
                await db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(node));
        }
示例#4
0
 public void GraphInit()
 {
     graph = new GraphMap
     {
         Id          = 1003,
         Name        = "TestMap",
         Graph       = new Graph(),
         IsDefault   = false,
         GraphString = string.Empty,
         NodeHistory = new System.Collections.Generic.List <string> {
             string.Empty
         },
         EdgeHistory = new System.Collections.Generic.List <string> {
             string.Empty
         },
         NodeHistoryString  = string.Empty,
         EdgeHistoryString  = string.Empty,
         CurrentEdgeIdToAdd = 1005
     };
     vertex = new TransportVertex
     {
         Name        = "TestVertex",
         Description = "TestDescr"
     };
     edge = new IntercityLink
     {
         Length       = 2843.874,
         Price        = 48.17,
         ServiceClass = 4,
         NodesPair    = new VerticesPair
         {
             FirstNodeId   = 1,
             RelatedNodeId = 2
         }
     };
 }