예제 #1
0
        public void GetBagInfo_AreEqual()
        {
            //Arrange
            var SystemUnderTest = new RestService();
            var dependency      = new GetBagInfoInput()
            {
                Bagtag     = "1234567890",
                DeviceName = "Apple",
                Station    = "123",
                Username   = "******",
                Version    = "1"
            };

            var expected = new GetBagInfoResponse()
            {
                StatusCode   = "0",
                FltCode      = "DL",
                FltDate      = DateTime.Now.ToString("MMMdd"),
                FltNum       = "1234",
                PaxName      = "Bill Gates",
                PaxItinerary = "MNL-NRT-MSP",
                Latitude     = "47.72980",
                Longitude    = "-122.14931"
            };
            //Act
            var actual = SystemUnderTest.GetBagInfo(dependency);

            //Assert
            Assert.AreEqual(expected.StatusCode, actual.StatusCode);
        }
        public GetBagInfoResponse GetBagInfo(GetBagInfoInput input)
        {
            //logger.Trace("Service : IRestService, Method : GetBagInfo , Request : GetBagInfoInput = {"Bagtag" : input.Bagtag, "DeviceName" : "Apple", "Station" : "123", "Version" : "1" };")
            GetBagInfoResponse getBagInfoResponse = new GetBagInfoResponse();

            getBagInfoResponse.FltCode      = "DL";
            getBagInfoResponse.FltDate      = DateTime.Now.ToString("MMMdd");
            getBagInfoResponse.FltNum       = "1234";
            getBagInfoResponse.ReturnCode   = "1";
            getBagInfoResponse.PaxName      = "Bill Gates";
            getBagInfoResponse.PaxItinerary = "MNL-NRT-MSP";
            getBagInfoResponse.Latitude     = "47.72980";
            getBagInfoResponse.Longitude    = "-122.14931";


            List <ScanPoint> scanHistory = new List <ScanPoint>();

            scanHistory.Add(newscanPoint("ic_checkin", "Checkin - MNL - Manila, Philippines"));
            scanHistory.Add(newscanPoint("ic_departure", "Departure - MNL - Manila, Philippines"));
            scanHistory.Add(newscanPoint("ic_arrival", "Arrival - NRT - Tokyo, Japan"));
            scanHistory.Add(newscanPoint("ic_departure", "Departure - NRT - Tokyo, Japan"));
            scanHistory.Add(newscanPoint("ic_arrival", "Arrival - MSP - Minneapolis, USA"));
            scanHistory.Add(newscanPoint("ic_departure", "Departure - MSP - Minneapolis, USA"));
            getBagInfoResponse.BagHistory = scanHistory.ToArray <ScanPoint>();

            //logger.Trace("Service : IRestService , Method : GetBagInfo , Response : GetBagInfoResponse = {"BagHistory": bagInfo.BagHistory, "ReturnCode":bagInfo.ReturnCode,"Message":bagInfo.Message};
            return(getBagInfoResponse);
        }
        public GetBagInfoResponse GetBagInfo(GetBagInfoInput input)
        {
            logger.Trace("Service : IRestService, Method : GetBagInfo , Request : GetBagInfoInput = {'Bagtag' : input.Bagtag, 'DeviceName' : 'Appl', 'Station' : '123', 'Version' : '1' };");
            GetBagInfoResponse getBagInfoResponse = new GetBagInfoResponse();

            getBagInfoResponse.FltCode      = "DL";
            getBagInfoResponse.FltDate      = DateTime.Now.ToString("MMMdd");
            getBagInfoResponse.FltNum       = "1234";
            getBagInfoResponse.StatusCode   = "0";
            getBagInfoResponse.PaxName      = "Bill Gates";
            getBagInfoResponse.PaxItinerary = "MNL-NRT-MSP";
            getBagInfoResponse.Latitude     = "47.636372";
            getBagInfoResponse.Longitude    = "-122.126888";


            List <ScanPoint> scanHistory = new List <ScanPoint>();

            scanHistory.Add(newscanPoint("ic_checkin", "Checkin - MNL - Manila, Philippines"));
            scanHistory.Add(newscanPoint("ic_departure", "Departure - MNL - Manila, Philippines"));
            scanHistory.Add(newscanPoint("ic_arrival", "Arrival - NRT - Tokyo, Japan"));
            scanHistory.Add(newscanPoint("ic_departure", "Departure - NRT - Tokyo, Japan"));
            scanHistory.Add(newscanPoint("ic_arrival", "Arrival - MSP - Minneapolis, USA"));
            scanHistory.Add(newscanPoint("ic_departure", "Departure - MSP - Minneapolis, USA"));
            getBagInfoResponse.BagHistory = scanHistory.ToArray <ScanPoint>();

            logger.Trace("Service : IRestService , Method : GetBagInfo , Response : GetBagInfoResponse = {'BagHistory': bagInfo.BagHistory, 'ReturnCode':bagInfo.ReturnCode,'Message':bagInfo.Message}");
            return(getBagInfoResponse);
        }
예제 #4
0
        private void ShowSearchResultExecuted()
        {
            //ProgressBarVisible = true;
            BagInfo mBagInfo = new BagInfo();

            if (Mvx.Resolve <IValidation>().Is10Digits(BagtagNo) && !String.IsNullOrEmpty(BagtagNo))
            {
                GetBagInfoInput baginput = new GetBagInfoInput()
                {
                    Bagtag = BagtagNo, DeviceName = "Apple", Station = "123", Username = "******", Version = "1"
                };
                var bagInfo = new GetBagInfoResponse();
                try
                {
                    if (Mvx.Resolve <IValidation>().ObjectIsNotNull(baginput))
                    {
                        bagInfo = Mvx.Resolve <IRestService>().GetBagInfo(baginput);
                    }
                }
                catch (Exception e)
                {
                    Mvx.Resolve <IUserDialogs>().Toast("An error occurred!", null);
                    _logger.Trace("ShowSearchResultExecuted ex: " + e.ToString() + "");
                }

                if (bagInfo.StatusCode == "0")
                {
                    BagScanPoint        scanPoint;
                    List <BagScanPoint> mscanHistory = new List <BagScanPoint>();
                    foreach (var item in bagInfo.BagHistory)
                    {
                        scanPoint           = new BagScanPoint();
                        scanPoint.Icon      = item.ScanType;
                        scanPoint.ScanPoint = item.Location;
                        scanPoint.ScanTime  = item.DateTime;
                        mscanHistory.Add(scanPoint);
                    }
                    mBagInfo.Bagtag        = BagtagNo;
                    mBagInfo.PaxName       = bagInfo.PaxName;
                    mBagInfo.PaxItinerary  = bagInfo.PaxItinerary;
                    mBagInfo.Latitude      = bagInfo.Latitude;
                    mBagInfo.Longitude     = bagInfo.Longitude;
                    mBagInfo.FltCode       = bagInfo.FltCode;
                    mBagInfo.FltDate       = bagInfo.FltDate;
                    mBagInfo.FltNum        = bagInfo.FltNum;
                    mBagInfo.BagScanPoints = mscanHistory;
                    ISqliteService <BagInfo> bagRepo = new SqliteService <BagInfo>();
                    var user = bagRepo.InsertUpdate(mBagInfo);
                    _navigationService.Navigate <BottomNavigationViewModel, BagInfo>(mBagInfo);
                    _navigationService.Navigate <BagInfoViewModel, BagInfo>(mBagInfo);
                }
            }
            else
            {
                Mvx.Resolve <IUserDialogs>().Alert("Bagtag no must contains 10 digits.", "Invalid Bagtag no!", "Dismiss");
            }

            //ProgressBarVisible = false;
        }
        /// <summary>
        /// delete after solving the issue in LoadBagInfoAsync
        /// </summary>
        private void testScanHistory()
        {
            GetBagInfoInput baginput = new GetBagInfoInput()
            {
                Bagtag = BagtagNo, DeviceName = "Apple", Station = "123", Username = "******", Version = "1"
            };
            var bagInfo = new GetBagInfoResponse();

            try
            {
                if (Mvx.Resolve <IValidation>().ObjectIsNotNull(baginput))
                {
                    bagInfo = Mvx.Resolve <IRestService>().GetBagInfo(baginput);
                }
            }
            catch (Exception)
            {
                Mvx.Resolve <IUserDialogs>().Toast("An error occurred!", null);
                //logger.Log(LogLevel.Info,e.ToString);
            }

            Name         = bagInfo.PaxName;
            Flight       = bagInfo.FltCode + bagInfo.FltNum;
            FlightDate   = bagInfo.FltDate;
            Itinerary    = bagInfo.PaxItinerary;
            BagLatitude  = bagInfo.Latitude;
            BagLongitude = bagInfo.Longitude;

            BagScanPoint        scanPoint;
            List <BagScanPoint> mscanHistory = new List <BagScanPoint>();

            foreach (var item in bagInfo.BagHistory)
            {
                scanPoint           = new BagScanPoint();
                scanPoint.Icon      = item.ScanType;
                scanPoint.ScanPoint = item.Location;
                scanPoint.ScanTime  = item.DateTime;
                mscanHistory.Add(scanPoint);
            }
            ScanHistory = mscanHistory;
        }
        private void ShowSearchResultExecuted()
        {
            //Sample
            var             bagInfo  = new GetBagInfoResponse();
            GetBagInfoInput baginput = new GetBagInfoInput()
            {
                Bagtag = "1234", DeviceName = "Apple", Station = "123", Username = "******", Version = "1"
            };

            try
            {
                bagInfo = Mvx.Resolve <IRestService>().GetBagInfo(baginput);
                var                 mBagInfo = new BagInfo();
                BagScanPoint        scanPoint;
                List <BagScanPoint> mscanHistory = new List <BagScanPoint>();
                foreach (var item in bagInfo.BagHistory)
                {
                    scanPoint           = new BagScanPoint();
                    scanPoint.Icon      = item.ScanType;
                    scanPoint.ScanPoint = item.Location;
                    scanPoint.ScanTime  = item.DateTime;
                    mscanHistory.Add(scanPoint);
                }
                mBagInfo.Bagtag        = "1111111111";
                mBagInfo.PaxName       = bagInfo.PaxName;
                mBagInfo.PaxItinerary  = bagInfo.PaxItinerary;
                mBagInfo.Latitude      = bagInfo.Latitude;
                mBagInfo.Longitude     = bagInfo.Longitude;
                mBagInfo.FltCode       = bagInfo.FltCode;
                mBagInfo.FltDate       = bagInfo.FltDate;
                mBagInfo.FltNum        = bagInfo.FltNum;
                mBagInfo.BagScanPoints = mscanHistory;
                _navigationService.Navigate <BottomNavigationViewModel, BagInfo>(mBagInfo);
                _navigationService.Navigate <BagInfoViewModel, BagInfo>(mBagInfo);
            }
            catch (Exception e)
            {
                Mvx.Resolve <IUserDialogs>().Toast("An error occurred!", null);
            }
        }