コード例 #1
0
ファイル: RouteVMService.cs プロジェクト: ShikuroD/Greenair
        public async Task <RoutePageVM> GetRoutePageViewModelAsync(string searchString, int pageIndex = 1)
        {
            List <RouteVM> ListRoutes = new List <RouteVM>();
            // var movies = await _service.GetMoviesAsync(searchString, genre);
            var Routes = await _service.getAllRouteAsync();

            var origin_name      = "";
            var destination_name = "";

            Routes = await _service.SortAsync(Routes, ORDER_ENUM.ORIGIN_NAME, ORDER_ENUM.DESCENDING);

            foreach (var item in Routes)
            {
                AirportDTO origin_airport = await _airportService.getAirportAsync(item.Origin);

                AirportDTO des_airport = await _airportService.getAirportAsync(item.Destination);

                origin_name      = origin_airport.AirportName;
                destination_name = des_airport.AirportName;
                RouteVM routeVM = new RouteVM(item.RouteId, origin_name, destination_name, item.Origin, item.Destination, item.Status, item.FlightTime.toString());
                ListRoutes.Add(routeVM);
            }
            // if (searchString != null)
            // {
            //     // Routes = await _service.getRouteByConditionsAsync(searchString, "", "");
            // }
            // var genres = await _service.GetGenresAsync();
            // var abc = _mapper.Map<IEnumerable<Route>, IEnumerable<RouteDTO>>(Routes);

            return(new RoutePageVM
            {
                Routes = PaginatedList <RouteVM> .Create(ListRoutes, pageIndex, pageSize)
            });
        }
コード例 #2
0
        public IActionResult ConnectRouteToClient(RouteVM routeVM)
        {
            //if (ModelState.IsValid)
            if (true)
            {
                try
                {
                    var route = _mapper.Map <Route>(routeVM);

                    var newClient = _routeApplicationService.ConnectRouteToClient(null);

                    if (newClient.Count > 0)
                    {
                        return(Ok(newClient));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
        }
コード例 #3
0
        public ActionResult Create(RouteVM routeVM)
        {
            _routeApplicationService.Add(routeVM);
            var routesVMs = _routeApplicationService.GetAll();

            return(View("Index", routesVMs));
        }
コード例 #4
0
        private void CboRoutes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RouteVM route = (sender as ComboBox).SelectedItem as RouteVM;
            var     boxes = _apiMobile.GetBoxesStockParents(new Guid(route.DT_RowId));

            grdTagsAvailable.ItemsSource = boxes;
            cboBoxTypes.ItemsSource      = boxes.Select(x => x.BoxType.Name).Distinct().ToList();
        }
コード例 #5
0
        public RouteVM GetRoute(Guid id)
        {
            var routes = _routeApplicationService.GetById(id);

            RouteVM RouteVM = _mapper.Map <RouteVM>(routes);

            return(RouteVM);
        }
コード例 #6
0
        public static void SeedData(IServiceProvider serviceProvider)
        {
            var clientService = serviceProvider.GetRequiredService <IClientApplicationService>();

            if (clientService.GetAll().Count == 0)
            {
                AddressVM addressVM = new AddressVM();
                addressVM.CEP       = "13276-130";
                addressVM.Estate    = "SP";
                addressVM.Street    = "Av. Onze de Agosto";
                addressVM.Number    = "623";
                addressVM.City      = "Valinhos";
                addressVM.District  = "Centro";
                addressVM.Reference = "";
                var addressService = serviceProvider.GetRequiredService <IAddressApplicationService>();
                addressVM = addressService.Add(addressVM);

                for (int i = 0; i < 50; i++)
                {
                    ClientVM client = new ClientVM();
                    client.Name           = $"Cliente - {i}";
                    client.Contact        = $"Contanto - {i}";
                    client.SaleIsFinished = false;
                    client.Phone          = "19-99999-9999";
                    client.Address        = addressVM;
                    clientService.Add(client);
                }

                var productService = serviceProvider.GetRequiredService <IProductApplicationService>();

                var routeService = serviceProvider.GetRequiredService <IRouteApplicationService>();
                for (int i = 0; i < 10; i++)
                {
                    RouteVM route = new RouteVM();
                    route.Name            = $"Rota - {i}";
                    route.KmDistance      = 100 + 1;
                    route.Truck           = $"Costallation - {i}";
                    route.HasOpenDelivery = false;
                    routeService.Add(route);
                }

                var paymentService = serviceProvider.GetRequiredService <IPaymentApplicationService>();

                PaymentMethodVM paymentMethodVM = new PaymentMethodVM();
                paymentMethodVM.MethodName = "Check";
                paymentMethodVM.Descrition = "Payment with check";
                paymentService.AddPaymentMethod(paymentMethodVM);
                paymentMethodVM.MethodName = "Money";
                paymentMethodVM.Descrition = "Payment with Money";
                paymentService.AddPaymentMethod(paymentMethodVM);
                paymentMethodVM.MethodName = "Bank bill";
                paymentMethodVM.Descrition = "Payment with Bank bill";
                paymentService.AddPaymentMethod(paymentMethodVM);
                paymentMethodVM.MethodName = "Credit";
                paymentMethodVM.Descrition = "Payment with Credit";
                paymentService.AddPaymentMethod(paymentMethodVM);
            }
        }
コード例 #7
0
        public ActionResult Edit(RouteVM routeVM)
        {
            _routeApplicationService.Update(routeVM);

            return(Json(new
            {
                success = true,
                Message = "OK"
            }));
        }
コード例 #8
0
        public override void Cleanup()
        {
            AlarmappVM.Cleanup();
            DataVM.Cleanup();
            RouteVM.Cleanup();
            TimerVM.Cleanup();
            VehiclesVM.Cleanup();

            base.Cleanup();
        }
コード例 #9
0
ファイル: Routes.xaml.cs プロジェクト: MrXeth/A3Farming
        /// <summary>
        /// datagrid adding new item handler
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event args</param>
        private void Data_AddingNewItem(object sender, AddingNewItemEventArgs e)
        {
            var mainWindow = (MainWindow)Application.Current.MainWindow;
            var routeVM    = new RouteVM()
            {
                Data             = mainWindow.Data,
                VehicleSelection = mainWindow.VehicleSelectionVM
            };

            e.NewItem = routeVM;
        }
コード例 #10
0
        public IActionResult GetBestRoute([FromRoute] string origin, string destination)
        {
            var routes = _repository.Get();

            var bestRoute = RouteService.BestRouteProcess(routes.Find(q => q.AirportName == origin), routes.Find(q => q.AirportName == destination));
            var result    = new RouteVM()
            {
                RoutePathDescription = bestRoute.RoutePathDescription, TotalCost = bestRoute.TotalCost
            };

            return(Ok(JsonSerializer.Serialize(result)));
        }
コード例 #11
0
        public ActionResult Index(int?departureId, int?destinationId, DateTime?dateOfDeparture)
        {
            if (departureId == null || destinationId == null || dateOfDeparture == null || destinationId == departureId)
            {
                return(PartialView("_FaultyInputPartial"));
            }

            IList <IList <Tgvs> >    calculatedRoutes = tgvService.GetJourneys((int)departureId, (int)destinationId, (DateTime)dateOfDeparture);
            IList <IList <RouteVM> > routes           = new List <IList <RouteVM> >();

            foreach (IList <Tgvs> calculatedRoute in calculatedRoutes)
            {
                IList <RouteVM> route = new List <RouteVM>();

                DateTime departureDate = (DateTime)dateOfDeparture;
                DateTime lastArrival   = departureDate;
                DateTime temp;

                foreach (Tgvs tgv in calculatedRoute)
                {
                    temp = departureDate.Add(tgv.TimeOfDeparture);

                    while (temp.CompareTo(lastArrival) <= 0)
                    {
                        temp = temp.AddDays(1);
                    }

                    RouteVM r = new RouteVM()
                    {
                        StartStation           = tgv.LineNavigation.DepartureNavigation.City,
                        EndStation             = tgv.LineNavigation.DestinationNavigation.City,
                        TimeOfDeparture        = temp,
                        AvailableSeatsBusiness = tgv.AvailableBusinessSeats,
                        AvailableSeatsEconomic = tgv.AvailableEconomicSeats,
                        PriceBusiness          = tgv.BasePriceBusiness,
                        PriceEconomic          = tgv.BasePriceEconomic,
                        TgvId         = tgv.Id,
                        DepartureId   = tgv.LineNavigation.Departure,
                        DestinationId = tgv.LineNavigation.Destination
                    };

                    lastArrival = temp.Add(tgv.LineNavigation.Duration);

                    r.TimeOfArrival = lastArrival;

                    route.Add(r);
                }

                routes.Add(route);
            }

            return(PartialView("_JourneyResultPartial", routes));
        }
コード例 #12
0
ファイル: RoutesVM.cs プロジェクト: MrXeth/A3Farming
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="data">data view model</param>
        /// <param name="vehicleSelection">vehicle selection</param>
        public RoutesVM(DataVM data, VehicleSelection vehicleSelection)
        {
            this.data        = data;
            VehicleSelection = vehicleSelection;

            foreach (var route in data.Data.Routes)
            {
                var routeVM = new RouteVM(route, data, vehicleSelection);
                RouteVMs.Add(routeVM);
            }

            RouteVMs.CollectionChanged += RouteVMs_CollectionChanged;
        }
コード例 #13
0
        public MainPage()
        {
            InitializeComponent();
            VMProp = this.BindingContext as RouteVM;

            VMProp.OneEvenHandler += Vm_OneEvenHandler;

            Task.Run(() => {
                Task.Delay(1000);
                Device.BeginInvokeOnMainThread(() => {
                    LoadingVision();
                });
            });
        }
コード例 #14
0
        public List <RouteVM> GetRoutesFromLocations(List <Location> locations, Ship ship, double capital)
        {
            List <RouteVM> routes = new List <RouteVM>();
            var            sellLocationsWithData = GetLocationData(locations);

            foreach (var location in sellLocationsWithData)
            {
                foreach (var purchaseCommodity in location.PurchaseCommodities)
                {
                    var sellLocations = GetSellLocations(purchaseCommodity);

                    foreach (var sellLocation in sellLocations)
                    {
                        double quantity;

                        if (capital / purchaseCommodity.PurchaseCost > ship.Capacity)
                        {
                            quantity = ship.Capacity;
                        }
                        else
                        {
                            quantity = capital / purchaseCommodity.PurchaseCost;
                        }

                        RouteVM route = new RouteVM()
                        {
                            Commodity        = purchaseCommodity,
                            PurchaseLocation = location,
                            SellLocation     = sellLocation,
                            Quantity         = quantity
                        };

                        var totalPurchaseCost = route.Commodity.PurchaseCost * route.Quantity;
                        var sellPrice         = GetSellCommodities(sellLocation)
                                                .FirstOrDefault(c => c.Name == route.Commodity.Name).SellPrice;
                        var totalSellPrice = sellPrice * route.Quantity;
                        var profit         = totalSellPrice - totalPurchaseCost;
                        route.Profit = profit;

                        routes.Add(route);
                    }
                }
            }

            return(routes);
        }
コード例 #15
0
        public IActionResult BuyTicket(int departureId, int destinationId, string dateOfDeparture)
        {
            DateTime date = Convert.ToDateTime(dateOfDeparture);

            IList <Tgvs>   journey      = tgvService.GetJourney(departureId, destinationId, date);
            ShoppingCartVM shoppingCart = new ShoppingCartVM();

            foreach (Tgvs tgv in journey)
            {
                if (tgv.TimeOfDeparture.CompareTo(date.TimeOfDay) < 0)
                {
                    date = date.AddDays(1);
                }

                RouteVM route = new RouteVM()
                {
                    StartStation           = tgv.LineNavigation.DepartureNavigation.City,
                    EndStation             = tgv.LineNavigation.DestinationNavigation.City,
                    TimeOfDeparture        = date.Date.Add(tgv.TimeOfDeparture),
                    TgvId                  = tgv.Id,
                    PriceEconomic          = tgv.BasePriceEconomic,
                    PriceBusiness          = tgv.BasePriceBusiness,
                    AvailableSeatsBusiness = tgv.AvailableBusinessSeats,
                    AvailableSeatsEconomic = tgv.AvailableEconomicSeats,
                    DepartureId            = tgv.LineNavigation.Departure,
                    DestinationId          = tgv.LineNavigation.Destination,
                    Amount                 = 1
                };

                tgv.Tickets             = null;
                tgv.LineNavigation.Tgvs = null;
                tgv.LineNavigation.DepartureNavigation   = null;
                tgv.LineNavigation.DestinationNavigation = null;

                route.TimeOfArrival = route.TimeOfDeparture.Add(tgv.LineNavigation.Duration);

                date = route.TimeOfArrival;

                shoppingCart.Content.Add(route);
            }

            HttpContext.Session.SetObject("ShoppingCart", shoppingCart);

            return(RedirectToAction("Index", "ShoppingCart"));
        }
コード例 #16
0
        public IActionResult AddRoute(RouteVM model)
        {
            if (ModelState.IsValid)
            {
                _unitOfWork.Routes.Create(new Route {
                    Price         = model.Price,
                    DepartureId   = int.Parse(model.Departure),
                    DetartureDate = model.DetartureDate,
                    ArrivalId     = int.Parse(model.Arrival),
                    ArrivalDate   = model.ArrivalDate,
                    BusId         = int.Parse(model.Bus)
                });

                _unitOfWork.Save();

                return(RedirectToAction("ViewRoutes"));
            }
            return(View(model));
        }
コード例 #17
0
        public BaseResult MergeRoute(RouteVM routeVM)
        {
            var result = new BaseResult();

            try
            {
                var route = Mapper.Map <Route>(routeVM);
                UnitOfWork.RouteDao.Merge(route);

                result.Success = true;
                result.Message = GeneralSuccessMessage;
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = GeneralErrorMessage;
            }
            return(result);
        }
コード例 #18
0
        public RouteVM Add(RouteVM entity)
        {
            try
            {
                var route = _mapper.Map <Route>(entity);

                _unitOfWork.Repository <Route>().Add(route);
                _unitOfWork.CommitSync();

                return(entity);
            }
            catch (CustomException exc)
            {
                throw exc;
            }
            catch (Exception ex)
            {
                throw CustomException.Create <ClientApplicationService>("Unexpected error fetching add route", nameof(this.Add), ex);
            }
        }
コード例 #19
0
        public bool IsRouteCodeExists(RouteVM route)
        {
            Query = "SELECT Code FROM Route WHERE Code = @code";

            Command = new SqlCommand(Query, Connection);

            Command.Parameters.Clear();
            Command.Parameters.Add("code", SqlDbType.VarChar);
            Command.Parameters["code"].Value = route.RouteCode;
            Connection.Open();
            Reader = Command.ExecuteReader();
            bool hasRow = false;

            if (Reader.HasRows)
            {
                hasRow = true;
            }
            Reader.Close();
            Connection.Close();
            return(hasRow);
        }
コード例 #20
0
      public async Task <IActionResult> Create([FromBody] CreateRouteVM data)
      {
          if (data != null)
          {
              try
              {
                  Route route = new Route();
                  route.Name               = data.name;
                  route.Description        = data.description;
                  route.TotalDistance      = data.totalDistance;
                  route.TotalElevationGain = data.totalElevationGain;
                  route.TotalElevationLoss = data.totalElevationLoss;
                  string[] cityState = ReverseGeocodeCoordinates(data.coordinates[0]);
                  route.City   = cityState[0];
                  route.State  = cityState[1];
                  route.UserId = int.Parse(data.userId);
                  _context.Routes.Add(route);
                  await _context.SaveChangesAsync();

                  int routeId = FindRouteId(route.Name);
                  CreateCoordinatesRows(data.coordinates, routeId);
                  CreateDistancesRows(data.distances, routeId);
                  CreateElevationsRows(data.elevations, routeId);
                  RouteVM routeVM = new RouteVM();
                  routeVM.id = routeId;
                  return(Ok(routeVM
                            ));
              }
              catch
              {
                  throw new System.Web.Http.HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
              }
          }
          else
          {
              return(NoContent());
          }
      }
コード例 #21
0
        public int AddRoute(RouteVM route)
        {
            Query =
                "INSERT INTO Route(Code,StartPlace,EndPlace) VALUES(@code, @startPlace, @endPlace)";

            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();
            Command.Parameters.Add("code", SqlDbType.VarChar);
            Command.Parameters["code"].Value = route.RouteCode;

            Command.Parameters.Add("startPlace", SqlDbType.VarChar);
            Command.Parameters["startPlace"].Value = route.StartPlace;

            Command.Parameters.Add("endPlace", SqlDbType.VarChar);
            Command.Parameters["endPlace"].Value = route.EndPlace;

            Connection.Open();

            int rowAffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(rowAffected);
        }
コード例 #22
0
        public List <RouteVM> GetAllRoutes()
        {
            Query = "SELECT * FROM Route";

            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            List <RouteVM> routes = new List <RouteVM>();

            while (Reader.Read())
            {
                RouteVM route = new RouteVM()
                {
                    RouteCode  = Reader["Code"].ToString(),
                    StartPlace = Reader["StartPlace"].ToString(),
                    EndPlace   = Reader["EndPlace"].ToString()
                };
                routes.Add(route);
            }
            Reader.Close();
            Connection.Close();
            return(routes);
        }
コード例 #23
0
 public string AddRoute(RouteVM route)
 {
     if (aTransportGateway.IsRouteCodeExists(route))
     {
         return("Route already added!!");
     }
     else
     {
         if (aTransportGateway.IsRouteAdded(route))
         {
             return("Route already added!!");
         }
         int rowAffected = aTransportGateway.AddRoute(route);
         if (rowAffected > 0)
         {
             return("Route added successfully!");
         }
         else
         {
             return("Failed to add row");
         }
     }
 }
コード例 #24
0
        public bool IsRouteAdded(RouteVM route)
        {
            Query = "SELECT StartPlace,EndPlace From Route WHERE StartPlace = @startPlace AND EndPlace = @endPlace";

            Command = new SqlCommand(Query, Connection);

            Command.Parameters.Clear();
            Command.Parameters.Add("startPlace", SqlDbType.VarChar);
            Command.Parameters["startPlace"].Value = route.StartPlace;

            Command.Parameters.Add("endPlace", SqlDbType.VarChar);
            Command.Parameters["endPlace"].Value = route.EndPlace;
            Connection.Open();
            Reader = Command.ExecuteReader();
            bool hasRow = false;

            if (Reader.HasRows)
            {
                hasRow = true;
            }
            Reader.Close();
            Connection.Close();
            return(hasRow);
        }
コード例 #25
0
        public IActionResult Post(RouteVM RouteVM)
        {
            //if (ModelState.IsValid)
            if (true)
            {
                try
                {
                    var newClient = _routeApplicationService.Add(RouteVM);

                    if (string.IsNullOrEmpty(newClient.DT_RowId))
                    {
                        return(Ok(newClient));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
        }
コード例 #26
0
        public RouteVM Update(RouteVM updated)
        {
            try
            {
                var   route       = _mapper.Map <Route>(updated);
                Route routeUpdate = _unitOfWork.Repository <Route>().GetById(route.Id);

                if (routeUpdate != null)
                {
                    routeUpdate.UpdateData(route);
                    _unitOfWork.Repository <Route>().Update(routeUpdate);
                    _unitOfWork.CommitSync();
                }
                return(updated);
            }
            catch (CustomException exc)
            {
                throw exc;
            }
            catch (Exception ex)
            {
                throw CustomException.Create <ClientApplicationService>("Unexpected error fetching update route", nameof(this.Update), ex);
            }
        }
コード例 #27
0
 public Task <RouteVM> AddAsync(RouteVM entity)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 public ActionResult AddRoute(RouteVM route)
 {
     ViewBag.Routes  = aTransportManager.GetAllRoutes();
     ViewBag.Message = aTransportManager.AddRoute(route);
     return(View());
 }
コード例 #29
0
 public Task <RouteVM> UpdateAsync(RouteVM updated)
 {
     throw new NotImplementedException();
 }
コード例 #30
0
 public AddRouteForm()
 {
     InitializeComponent();
     DataContext = new RouteVM();
 }