예제 #1
0
        public ActionResult Create(OdcinekPunktowany route, int routeListId)
        {
            bool routeExistsInRouteList = false;
            var  routes = _routeListService.GetRoutesFromRouteList(_dbContext.OdcinekPunktowany.ToList(), routeListId);

            if (ModelState.IsValid && (routeExistsInRouteList = _routeListService.EquivalentRouteExistsInRouteList(routes, route)) == false)
            {
                route.WykazTrasId = routeListId;
                _dbContext.OdcinekPunktowany.Add(route);
                _dbContext.SaveChanges();
                return(RedirectToRoute("RouteCreated"));
            }
            else
            {
                var places         = _dbContext.Miejsce.ToList();
                var mountainGroups = _dbContext.GrupaGorska.ToList();
                ViewBag.Places      = new SelectList(places, "Id", "Nazwa");
                ViewBag.RouteExists = routeExistsInRouteList;
                ViewBag.Groups      = new SelectList(mountainGroups, "Id", "Nazwa", null, "RegionGorski");
                return(View(route));
            }
        }