Example #1
0
        public async Task <RouteUpdateTransactionResponse> Handle(RouteUpdateTransactionRequest request, CancellationToken cancellationToken)
        {
            var Route = await RouteRepository.Update(
                Conversions.FromModelToDTO(request.Route)
                , cancellationToken);

            RouteUpdateTransactionResponse response = new RouteUpdateTransactionResponse();

            response.Route = Conversions.FromDTOToModel(Route);
            return(response);
        }
Example #2
0
        public ActionResult Edit(Route model)
        {
            var _context = new ApplicationDbContext();

            model.SinkNodes = _context.SinkNodes.ToList();
            if (model.SinkNodes.Count() == 0)
            {
                model.SinkNodes = new List <SinkNode>();
            }

            Repo.Update(model);

            return(View());
        }
Example #3
0
 public bool Update(string primarykey, string columToModify, object newValue)
 {
     try
     {
         dbConnection.Open();
         return(_routeRepository.Update(primarykey, columToModify, newValue));
     }
     catch (System.Exception)
     {
         return(false);
     }
     finally
     {
         dbConnection.Close();
     }
 }
        public void Update_Route()
        {
            string routeName = "Test Route to Update";
            string routeNameUpdated = "Test Route Updated";

            // Add to database
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                RouteRepository routeRepository = new RouteRepository(ctx);
                routeRepository.Add(new Route { Name = routeName, TimeTable = new TimeTable { Name = "TimeTable" } });
                routeRepository.SaveChanges();
            }

            // Find and update it
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                List<Route> routes = ctx.Routes.Where(route => route.Name == routeName).ToList();
                Assert.AreEqual(1, routes.Count());

                RouteRepository routeRepository = new RouteRepository(ctx);
                routes[0].Name = routeNameUpdated;
                routeRepository.Update(routes[0]);
                routeRepository.SaveChanges();
            }

            // Check that the new name is there
            using (ThamesClipperContext ctx = new ThamesClipperContext())
            {
                List<Route> routes = ctx.Routes.Where(route => route.Name == routeNameUpdated).ToList();
                Assert.AreEqual(1, routes.Count());
            }
        }