Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "RouteId,SignalId")] RouteSignal routeSignal)
        {
            MOE.Common.Models.Repositories.IRouteRepository routeRepository = MOE.Common.Models.Repositories.RouteRepositoryFactory.Create();
            var route = routeRepository.GetRouteByID(routeSignal.RouteId);

            if (route.RouteSignals == null)
            {
                route.RouteSignals = new List <RouteSignal>();
            }
            routeSignal.Order = route.RouteSignals.Count + 1;

            if (TryValidateModel(routeSignal))
            {
                routeSignalsRepository.Add(routeSignal);
            }
            return(Content(routeSignal.Id.ToString()));
        }