示例#1
0
        public IHttpActionResult PutGama(int id, Gama gama)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gama.Idgama)
            {
                return(BadRequest());
            }

            db.Entry(gama).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GamaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, Gama gama)
        {
            if (id != gama.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gama);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GamaExists(gama.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(gama));
        }
示例#3
0
        public IHttpActionResult GetGama(int id)
        {
            Gama gama = db.Gama.Find(id);

            if (gama == null)
            {
                return(NotFound());
            }

            return(Ok(gama));
        }
示例#4
0
        public async Task <IActionResult> Create(Gama gama)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gama);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gama));
        }
示例#5
0
        public IHttpActionResult PostGama(Gama gama)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Gama.Add(gama);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = gama.Idgama }, gama));
        }
示例#6
0
        public IHttpActionResult DeleteGama(int id)
        {
            Gama gama = db.Gama.Find(id);

            if (gama == null)
            {
                return(NotFound());
            }

            db.Gama.Remove(gama);
            db.SaveChanges();

            return(Ok(gama));
        }
        public void PerformUpdate_GivenCompleteUpdateRequested_PerformsCorrectUpdate()
        {
            //Arrange
            var alfa = new Alfa();
            var beta = new Beta(alfa);
            var gama = new Gama(alfa, beta);

            var nodeA = new PropertyNode(nameof(alfa.A), alfa);
            var nodeB = new PropertyNode(nameof(alfa.B), alfa);
            var nodeC = new PropertyNode(nameof(beta.C), beta);
            var nodeD = new PropertyNode(nameof(beta.D), beta);
            var nodeE = new PropertyNode(nameof(gama.E), gama);
            var nodeF = new PropertyNode(nameof(gama.F), gama);

            var reactor = new Reactor("R1");

            reactor.CreateDependency(nodeA, nodeE);
            reactor.CreateDependency(nodeA, nodeB);
            reactor.CreateDependency(nodeA, nodeD);
            reactor.CreateDependency(nodeC, nodeD);
            reactor.CreateDependency(nodeB, nodeE);
            reactor.CreateDependency(nodeB, nodeF);
            reactor.CreateDependency(nodeD, nodeF);
            reactor.CreateDependency(nodeE, nodeF);

            //Act
            reactor.PerformUpdate();

            //Assert
            var updateLog = reactor.LastUpdateLog;
            int indexA    = updateLog.IndexOf(nodeA);
            int indexB    = updateLog.IndexOf(nodeB);
            int indexC    = updateLog.IndexOf(nodeC);
            int indexD    = updateLog.IndexOf(nodeD);
            int indexE    = updateLog.IndexOf(nodeE);
            int indexF    = updateLog.IndexOf(nodeF);

            Assert.IsTrue(updateLog.Count == 6);
            Assert.IsTrue(indexF > indexB && indexF > indexD && indexF > indexE);
            Assert.IsTrue(indexE > indexB && indexE > indexA);
            Assert.IsTrue(indexB > indexA);
            Assert.IsTrue(indexD > indexA && indexD > indexC);
        }