Exemplo n.º 1
0
        private void Submit(object sender, RoutedEventArgs e)
        {
            dynamic fromCity   = fromCitiesList.SelectedItem;
            int     fromCityId = fromCity.Id;

            dynamic toCity   = toCitiesList.SelectedItem;
            int     toCityId = toCity.Id;

            var route = new Route
            {
                Id         = existingRoute?.Id ?? routeService.GetId(),
                FromCityId = fromCityId,
                ToCityId   = toCityId,
                StartDate  = startDatePicker.SelectedDate.GetValueOrDefault(),
                EndDate    = endDatePicker.SelectedDate.GetValueOrDefault(),
                Price      = double.Parse(priceInput.Text),
                IsFlight   = true
            };

            if (existingRoute == null)
            {
                routeService.Create(route);
            }
            else
            {
                routeService.Update(route);
            }

            this.Close();
        }
        public IHttpActionResult Create(RouteDTO dto)
        {
            var model = _mapper.Map <RouteModel>(dto);

            model = _routeService.Create(model);

            return(Ok(model.Id));
        }
Exemplo n.º 3
0
        public ActionResult <Route> Create([FromBody] RouteDTO route)
        {
            var r  = _RouteService.Create(route);
            var id = r.Id;

            var list = _StopToRouteService.AddStops(route.Stops, id);

            return(Ok(r));
        }