Esempio n. 1
0
        public int CheckOut(UserLocations location)
        {
            var tax   = this._accessor(location);
            var total = tax.Calculate() + 100;

            return(total);
        }
Esempio n. 2
0
        public async Task <ResultLookup> LastKnownLocation(string userId, AppDbContext context)
        {
            if (UserLocations.TryGetValue(userId, out var location))
            {
                var nextLookupPossible = location.LastUpdated.AddMinutes(2);
                if (nextLookupPossible > DateTimeOffset.UtcNow)
                {
                    return(new ResultLookup()
                    {
                        SystemName = location.SystemName,
                        NextLookupIn = nextLookupPossible
                    });
                }
            }

            if (location == null)
            {
                location = new UserLocation();
                UserLocations.TryAdd(userId, location);
            }
            var eliteData = await FrontierApi.GetDataFor(context, userId);

            location.LastUpdated = DateTimeOffset.UtcNow;
            location.UserId      = userId;
            location.SystemName  = eliteData.LastSystem?.Name.ToString();
            return(new ResultLookup()
            {
                SystemName = location.SystemName,
                NextLookupIn = location.LastUpdated.AddMinutes(2)
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Get location history by userId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public UserLocations GetLocation(string userId)
        {
            if (userId == null)
            {
                return(null);
            }
            ObjectId id;

            if (ObjectId.TryParse(userId, out id))
            {
                UserLocations userLocations = UserLocations.FindOne(Query.EQ(USERLOCATIONS.ID, id));
                return(userLocations == null ? null : userLocations);
            }
            return(null);
        }
Esempio n. 4
0
        //Share user location
        public ActionResult ShareUserLocation(string userId, double longtitude, double lattitude)
        {
            if (userId == null)
            {
                return(View());
            }
            UserLocations userLocations = UserLocationsContext.GetLocation(userId);

            if (userLocations == null)
            {
                List <Location> locations = new List <Location>();
                locations.Add(new Location(longtitude, lattitude));
                userLocations = new UserLocations(ObjectId.Parse(userId), locations);
            }
            userLocations.locations.Add(new Location(longtitude, lattitude));
            return(View());
        }
Esempio n. 5
0
        //
        // GET: /Locations/
        public ActionResult Index(bool showEditColumns)
        {
            var userId   = Membership.GetUser().ProviderUserKey;
            var response = _locationsService.GetLocationByUser((Guid)userId);
            List <LocationDTO> locations = (List <LocationDTO>)response.Values;
            var model = new UserLocations();

            model.UserId    = (Guid)userId;
            model.Locations = locations.Select(loc => new AddressViewModel
            {
                CEP          = loc.CEP,
                LocationId   = loc.locationId,
                More         = loc.More,
                Neighborhood = loc.Neighborhood,
                Number       = loc.Number,
                Street       = loc.Street,
                UF           = loc.UF,
                City         = loc.City,
                Address      = loc.Street + " , " + loc.Number
            });
            model.ShowEditColumns = showEditColumns;
            return(PartialView("Locations", model));
        }
Esempio n. 6
0
        //public void RemoveUserLocation(int Id)
        //{
        //    foreach (UserLocation ul in UserLocations)
        //    {
        //        if (ul.Id == Id)
        //        {
        //            UserLocations.Remove(ul);
        //            break;
        //        }
        //    }

        //}

        //Added by ZaySoe on 07-Nov-2018
        public void RemoveUserLocation(int Id, int depth, bool isLabCode)
        {
            if (isLabCode)
            {
                foreach (UserLocation ul in UserLocations)
                {
                    if (Convert.ToInt32(ul.LabCode) == Id)
                    {
                        UserLocations.Remove(ul);
                        break;
                    }
                }
            }
            else
            {
                ArrayList delUserLocList = new ArrayList();
                if (depth == 0)
                {
                    for (int i = 0; i < UserLocations.Count; i++)
                    {
                        UserLocations.RemoveAt(i);
                    }
                }
                else if (depth == 1)
                {
                    for (int i = 0; i < UserLocations.Count; i++)
                    {
                        if (UserLocations[i].province.Id == Id)
                        {
                            delUserLocList.Add(UserLocations[i]);
                        }
                    }
                }
                else if (depth == 2)
                {
                    for (int i = 0; i < UserLocations.Count; i++)
                    {
                        if (UserLocations[i].District.Id == Id)
                        {
                            delUserLocList.Add(UserLocations[i]);
                        }
                    }
                }
                else if (depth == 3)
                {
                    for (int i = 0; i < UserLocations.Count; i++)
                    {
                        if (UserLocations[i].LLG.Id == Id)
                        {
                            delUserLocList.Add(UserLocations[i]);
                        }
                    }
                }
                else if (depth == 4)
                {
                    for (int i = 0; i < UserLocations.Count; i++)
                    {
                        if (UserLocations[i].Id == Id)
                        {
                            delUserLocList.Add(UserLocations[i]);
                        }
                    }
                }

                foreach (UserLocation ul in delUserLocList)
                {
                    UserLocations.Remove(ul);
                }
            }
        }