Пример #1
0
        public static Task <int> DeleteItinerary(ItineraryRisk risk)
        {
            var primitive = new PrimitiveItineraryRisk(risk);
            var database  = new SQLiteAsyncConnection(App.FilePath);

            return(database.DeleteAsync <PrimitiveItineraryRisk>(risk.Id));
        }
        public void Insert_Itinerary_Risk()
        {
            using var scope = _factory.Services.CreateScope();
            var           database = scope.ServiceProvider.GetService <IDatabaseEngine>();
            DateTime      now      = DateTime.UtcNow;
            ItineraryRisk risk     = new ItineraryRisk(now, "token");

            Assert.NotEqual(-1, database.Insert_Itinerary_Risk(risk));
        }
        public void Get_Itinerary_Risk_By_ID()
        {
            using var scope = _factory.Services.CreateScope();
            var           database = scope.ServiceProvider.GetService <IDatabaseEngine>();
            DateTime      now      = DateTime.UtcNow;
            ItineraryRisk risk     = new ItineraryRisk(now, "id_test");
            var           id       = database.Insert_Itinerary_Risk(risk);

            Assert.NotNull(database.Get_Itinerary_Risk_By_ID(id));
        }
Пример #4
0
        private async void SaveItineraryRisk(ItineraryRisk risk)
        {
            var primitiveRisk = new PrimitiveItineraryRisk(risk);
            var conn          = new SQLiteAsyncConnection(App.FilePath);
            await conn.CreateTableAsync <PrimitiveItineraryRisk>();

            primitiveRisk.Created = DateTime.Today;
            await conn.InsertAsync(primitiveRisk);

            await conn.CloseAsync();
        }
Пример #5
0
 public ItineraryRiskWrapper(ItineraryRisk itineraryRisk)
 {
     TotalItineraryRisk     = itineraryRisk.TotalItineraryRisk;
     LocationItineraryRisks = new Dictionary <string, int>();
     for (int i = 0; i < itineraryRisk.LocationItineraryRisks.Count; i++)
     {
         LocationItineraryRisks.Add(itineraryRisk.LocationItineraryRisks.Keys.ElementAt(i).ToString(), itineraryRisk.LocationItineraryRisks.Values.ElementAt(i));
         // TODO:
         // Handle the user making a location part of a different itinerary
     }
     Created = itineraryRisk.Created;
     ID      = itineraryRisk.ID;
 }
        public void Get_All_Itinerary_Risks()
        {
            using var scope = _factory.Services.CreateScope();
            var           database = scope.ServiceProvider.GetService <IDatabaseEngine>();
            DateTime      now      = DateTime.UtcNow;
            ItineraryRisk risk     = new ItineraryRisk(now, "token2");
            var           count    = database.Get_All_Itinerary_Risks().Count;

            database.Insert_Itinerary_Risk(risk);
            count++;
            Assert.NotEmpty(database.Get_All_Itinerary_Risks());
            Assert.Equal(count, database.Get_All_Itinerary_Risks().Count);
        }
        public PrimitiveItineraryRisk(ItineraryRisk risk)
        {
            Created            = risk.Created;
            AccessToken        = risk.UserAccessToken;
            TotalItineraryRisk = risk.TotalItineraryRisk;

            /*var tempDictionary = new Dictionary<string, int>();
             * for(int i = 0; i <  risk.LocationItineraryRisks.Count; i++)
             * {
             *  tempDictionary.Add(risk.LocationItineraryRisks.Keys.ElementAt(i).ToString(), risk.LocationItineraryRisks.Values.ElementAt(i));
             * }*/
            LocationItineraryRisks = JsonConvert.SerializeObject(risk.LocationItineraryRisks);
        }
Пример #8
0
        /// <summary>
        /// Initializes a new instance for the <see cref="ViewItineraryViewModel" /> class.
        /// </summary>
        public ViewItineraryViewModel(INavigation navigation, ItineraryRisk itineraryRisk)
        {
            var locations = itineraryRisk.LocationItineraryRisks;

            Navigation = navigation;
            Locations  = locations;
            cardItems  = new ObservableCollection <ItineraryRiskDetail>();
            var sortedLocations = from entry in locations orderby entry.Value descending select entry;

            foreach (var risk in sortedLocations)
            {
                cardItems.Add(new ItineraryRiskDetail(risk.Key.Region.Suburb, risk.Value));
            }

            AverageRisk = itineraryRisk.TotalItineraryRisk;
            CardColour  = ItineraryRiskDetail.RiskGradientEnd[AverageRisk];
            Date        = itineraryRisk.Created;
            Risk        = ItineraryRiskDetail.RiskDescription[AverageRisk];
        }
        public void DatabaseServiceSuccessfullyInsertsItineraryToDatabse()
        {
            using var scope = _factory.Services.CreateScope();
            // Arrange
            var database = scope.ServiceProvider.GetService <IDatabaseEngine>();

            var token = Guid.NewGuid().ToString();

            var user = new User(token, "notificationTest2");

            database.Insert_User(user);

            var itineraryRisk = new ItineraryRisk(DateTime.Now, token);

            // Act
            int itineraryID = database.Insert_Itinerary_Risk(itineraryRisk);
            var resultFromGetItineraryRisksByToken = database.Get_Itinerary_Risks_By_Token(token);
            var resultFromGetAllItineraryRisks     = database.Get_All_Itinerary_Risks();

            // Assert
            Assert.NotEmpty(resultFromGetItineraryRisksByToken);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewItineraryPage" /> class.
 /// </summary>
 public ViewItineraryPage(ItineraryRisk itineraryRisk)
 {
     InitializeComponent();
     BindingContext = new ViewItineraryViewModel(Navigation, itineraryRisk);
 }