/// <summary>
        /// Update the latitude/longitude of this object.
        /// </summary>
        /// <param name="loc">Location information to update this object with.</param>
        /// <returns></returns>
        public bool SetLocation(ILocationModel loc)
        {
            bool coordUpdated = false;

            double locLatitue   = loc == null ? double.NaN : loc.Latitude;
            double locLongitude = loc == null ? double.NaN : loc.Longitude;

            if (this.Latitude != locLatitue)
            {
                this.Latitude = locLatitue;
                coordUpdated  = true;
            }

            if (this.Longitude != locLongitude)
            {
                this.Longitude = locLongitude;
                coordUpdated   = true;
            }

            if (coordUpdated)
            {
                this.LocationDisplayName = null;
            }

            return(coordUpdated);
        }
        public ILocationModel Update(ILocationModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = LocationsRepository.Get(model.Id.Value);

            // Check if we would be applying identical information, if we are, just return the original
            // ReSharper disable once SuspiciousTypeConversion.Global
            if (LocationMapper.AreEqual(model, existingEntity))
            {
                return(LocationMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            LocationMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            LocationsRepository.Update(LocationMapper.MapToEntity(model));
            // Try to Save Changes
            LocationsRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
        public async Task <ActionResult> Index(CancellationToken cancellationToken)
        {
            ViewData[Constant.FormTitle] = "ADD Location";
            ILocationModel model = await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, GetCanellationToken(cancellationToken));

            return(View(model));
        }
 /// <summary>
 /// Set the distance away for all location model instances in this collection.
 /// </summary>
 /// <param name="loc"></param>
 public void SetDistancesAway(ILocationModel loc)
 {
     foreach (var item in this)
     {
         item.SetDistanceAway(loc);
     }
 }
        public ILocationModel Create(ILocationModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateIDIsNull(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Search for an Existing Record (Don't allow Duplicates
            var results = Search(LocationMapper.MapToSearchModel(model));

            if (results.Any())
            {
                return(results.First());
            }                                              // Return the first that matches
            // Map model to a new entity
            var newEntity = LocationMapper.MapToEntity(model);

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            LocationsRepository.Add(newEntity);
            // Try to Save Changes
            LocationsRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
 public override void SetCurrentLocation(ILocationModel loc)
 {
     if (loc != null)
     {
         Api.SetLocation(loc.Latitude, loc.Longitude, 0);
     }
 }
Exemple #7
0
 /// <summary>
 /// Converts a ILocationModel into a BasicGeoposition object.
 /// </summary>
 /// <param name="loc">ILocationModel to convert to BasicGeoposition.</param>
 /// <returns>BasicGeoposition instance representing this ILocationModel.</returns>
 public static BasicGeoposition AsBasicGeoposition(this ILocationModel loc)
 {
     return(new BasicGeoposition()
     {
         Latitude = loc.Latitude,
         Longitude = loc.Longitude
     });
 }
 public virtual bool AreEqual(ILocationModel model, ILocation entity)
 {
     return NameableEntityMapper.AreEqual(model, entity)
         // Location Properties
         && model.StartYear == entity.StartYear
         // Related Objects
         && model.FirstIssueAppearanceId == entity.FirstIssueAppearanceId
         && model.PrimaryImageFileId == entity.PrimaryImageFileId
         ;
 }
 public virtual bool AreEqual(ILocationModel model, ILocation entity)
 {
     return(NameableEntityMapper.AreEqual(model, entity)
            // Location Properties
            && model.StartYear == entity.StartYear
            // Related Objects
            && model.FirstIssueAppearanceId == entity.FirstIssueAppearanceId &&
            model.PrimaryImageFileId == entity.PrimaryImageFileId
            );
 }
 /// <summary>
 /// Validates latitude and longitude values.
 /// </summary>
 /// <param name="loc">Location model object to validate.</param>
 /// <returns>True if valid, else false.</returns>
 public static bool Validate(ILocationModel loc)
 {
     if (loc == null)
     {
         return(false);
     }
     else
     {
         return(Validate(loc.Latitude, loc.Longitude));
     }
 }
        public override void SetCurrentLocation(ILocationModel loc)
        {
            var metrics = new Dictionary <string, double>();

            if (loc != null)
            {
                metrics.Add("Latitude", loc.Latitude);
                metrics.Add("Longitude", loc.Longitude);
            }
            HockeyClient.Current.TrackEvent("SetCurrentLocation", null, metrics);
        }
Exemple #12
0
        /// <summary>
        /// Sets the current location to the analytics service.
        /// </summary>
        /// <param name="loc">Location value to log</param>
        public virtual void SetCurrentLocation(ILocationModel loc)
        {
            if (loc != null)
            {
                var metrics = new Dictionary <string, string>();
                metrics.Add("LocationDisplayName", loc.LocationDisplayName);
                metrics.Add("Latitude", loc.Latitude.ToString());
                metrics.Add("Longitude", loc.Longitude.ToString());

                this.Event("CurrentLocation", metrics);
            }
        }
        public async Task <ActionResult> IndexEdit(string hdnLocationId, CancellationToken cancellationToken)
        {
            if (System.Convert.ToInt64(hdnLocationId) > 0)
            {
                ViewData[Constant.FormTitle] = "EDIT Location";
                ILocationModel model = await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, hdnLocationId, GetCanellationToken(cancellationToken));

                ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess];
                return(View("Index", model));
            }
            else
            {
                return(Redirect("~/LocationSearch/Index"));
            }
        }
        public TeacherPresenter(ITeacherView view)
        {
            classScheduleHelper = new ClassScheduleHelper();

            teacherView = view;
            teacherModel = new TeacherModel();
            locationModel = new LocationModel();

            teacherView.AddTeacher += TeacherView_AddTeacher;
            teacherView.DeleteTeacher += TeacherView_DeleteTeacher;
            teacherView.ReloadDataGridView += TeacherView_ReloadDataGridView;
            teacherView.CreateEditTeacherView += TeacherView_CreateEditTeacherView;

            teacherView.LocationList = GetAllLocationList();
        }
        /// <summary>
        /// Retrieves a formatted address for a given location.
        /// </summary>
        /// <param name="loc">Location to geocode.</param>
        /// <returns>String name representing the specified location.</returns>
        public async Task <string> GetAddressAsync(ILocationModel loc, CancellationToken ct)
        {
            // Reverse geocode the specified geographic location.
            var result = await MapLocationFinder.FindLocationsAtAsync(loc?.AsGeoPoint()).AsTask(ct);

            // If the query returns results, display the name of the town
            // contained in the address of the first result.
            if (result.Status == MapLocationFinderStatus.Success)
            {
                return(loc.LocationDisplayName = result?.Locations[0].Address?.FormattedAddress);
            }
            else
            {
                return(loc.LocationDisplayName = null);
            }
        }
        /// <summary>
        /// Retrieves the city, state, and country for a given location.
        /// </summary>
        /// <param name="loc">Location to geocode.</param>
        /// <param name="ct">Cancellation token.</param>
        /// <returns>String name representing the specified location.</returns>
        public async Task <string> GetCityStateCountryAsync(ILocationModel loc, CancellationToken ct)
        {
            // Reverse geocode the specified geographic location.
            var result = await MapLocationFinder.FindLocationsAtAsync(loc?.AsGeoPoint()).AsTask(ct);

            // If the query returns results, display the name of the town
            // contained in the address of the first result.
            if (result.Status == MapLocationFinderStatus.Success)
            {
                return(loc.LocationDisplayName = this.ConcatAddressParts(3, result.Locations[0].Address?.Town, result.Locations[0].Address?.Region, result.Locations[0].Address?.Country, result.Locations[0].Address?.Continent));
            }
            else
            {
                return(loc.LocationDisplayName = null);
            }
        }
        public AViewModel(IBusServiceModel busServiceModel, IAppDataModel appDataModel, ILocationModel locationModel)
        {
            this.lazyBusServiceModel = busServiceModel;
            this.lazyAppDataModel = appDataModel;

            if (!IsInDesignMode)
            {
                locationTracker = new LocationTracker();
                operationTracker = new AsyncOperationTracker();
            }

            // Set up the default action, just execute in the same thread
            UIAction = (uiAction => uiAction());

            eventsRegistered = false;
        }
        public TeacherTrainingSchedulePresenter(ITeacherTrainingScheduleView view)
        {
            classScheduleHelper = new ClassScheduleHelper();

            teacherTrainingScheduleView = view;

            teacherModel = new TeacherModel();
            locationModel = new LocationModel();
            teacherTrainingScheduleModel = new TeacherTrainingScheduleModel();

            teacherTrainingScheduleView.AddTeacherTrainingSchedule += TeacherTrainingScheduleView_AddTeacherTrainingSchedule;
            teacherTrainingScheduleView.DeleteTeacherTrainingSchedule += TeacherTrainingScheduleView_DeleteTeacherTrainingSchedule;
            teacherTrainingScheduleView.ReloadDataGridView += TeacherTrainingScheduleView_ReloadDataGridView;

            teacherTrainingScheduleView.Location = GetAllLocationList();
            teacherTrainingScheduleView.Teacher = GetAllTeacherList();
        }
Exemple #19
0
        public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var entity = LocationsMockingSetup.DoMockingSetupForLocation(1);
            var mockLocationsRepository = LocationsMockingSetup.DoMockingSetupForRepository();

            mockLocationsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => entity.Object);
            var            businessWorkflow = new LocationsBusinessWorkflow(mockLocationsRepository.Object, new LocationMapper());
            var            model            = LocationsMockingSetup.DoMockingSetupForLocationModel(1);
            ILocationModel result           = null;

            // Act
            try { result = businessWorkflow.Update(model.Object); }
            catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ }
            // Assert
            Assert.NotNull(result);
            Assert.Equal("/TEST/KING-STEPHEN", result.ApiDetailUrl);
            Assert.Null(result.UpdatedDate);
        }
 /// <summary>
 /// Gets the distance away from a specified location object.
 /// </summary>
 /// <param name="loc">Location object to calculate distance away with.</param>
 /// <returns>Distance amount.</returns>
 public double GetDistanceTo(ILocationModel loc)
 {
     if (loc != null)
     {
         var r    = IsMetric ? 6371 : 3960;
         var dLat = ToRadian(this.Latitude - loc.Latitude);
         var dLon = ToRadian(this.Longitude - loc.Longitude);
         var a    = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
                    Math.Cos(ToRadian(loc.Latitude)) * Math.Cos(ToRadian(this.Latitude)) *
                    Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
         var c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a)));
         var d = r * c;
         return(Math.Round(d, DistanceDecimalPlaces));
     }
     else
     {
         return(double.NaN);
     }
 }
 public ILocationModel Create(ILocationModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateIDIsNull(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Search for an Existing Record (Don't allow Duplicates
     var results = Search(LocationMapper.MapToSearchModel(model));
     if (results.Any()) { return results.First(); } // Return the first that matches
     // Map model to a new entity
     var newEntity = LocationMapper.MapToEntity(model);
     newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
     newEntity.UpdatedDate = null;
     newEntity.Active = true;
     // Add it
     LocationsRepository.Add(newEntity);
     // Try to Save Changes
     LocationsRepository.SaveChanges();
     // Return the new value
     return Get(newEntity.Id);
 }
 public virtual void MapToEntity(ILocationModel model, ref ILocation entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Location Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance   = (Issue)model.FirstIssueAppearance?.MapToEntity();
     entity.PrimaryImageFileId     = model.PrimaryImageFileId;
     entity.PrimaryImageFile       = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.LocationAliases          = model.LocationAliases?.Where(i => i.Active).Select(LocationAliasMapperExtensions.MapToEntity).ToList();
     entity.LocationAppearedInIssues = model.LocationAppearedInIssues?.Where(i => i.Active).Select(LocationAppearedInIssueMapperExtensions.MapToEntity).ToList();
     entity.LocationIssues           = model.LocationIssues?.Where(i => i.Active).Select(LocationIssueMapperExtensions.MapToEntity).ToList();
     entity.LocationMovies           = model.LocationMovies?.Where(i => i.Active).Select(LocationMovieMapperExtensions.MapToEntity).ToList();
     entity.LocationStoryArcs        = model.LocationStoryArcs?.Where(i => i.Active).Select(LocationStoryArcMapperExtensions.MapToEntity).ToList();
     entity.LocationVolumes          = model.LocationVolumes?.Where(i => i.Active).Select(LocationVolumeMapperExtensions.MapToEntity).ToList();
 }
 public virtual void MapToEntity(ILocationModel model, ref ILocation entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Location Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance = (Issue)model.FirstIssueAppearance?.MapToEntity();
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.LocationAliases = model.LocationAliases?.Where(i => i.Active).Select(LocationAliasMapperExtensions.MapToEntity).ToList();
     entity.LocationAppearedInIssues = model.LocationAppearedInIssues?.Where(i => i.Active).Select(LocationAppearedInIssueMapperExtensions.MapToEntity).ToList();
     entity.LocationIssues = model.LocationIssues?.Where(i => i.Active).Select(LocationIssueMapperExtensions.MapToEntity).ToList();
     entity.LocationMovies = model.LocationMovies?.Where(i => i.Active).Select(LocationMovieMapperExtensions.MapToEntity).ToList();
     entity.LocationStoryArcs = model.LocationStoryArcs?.Where(i => i.Active).Select(LocationStoryArcMapperExtensions.MapToEntity).ToList();
     entity.LocationVolumes = model.LocationVolumes?.Where(i => i.Active).Select(LocationVolumeMapperExtensions.MapToEntity).ToList();
 }
 public virtual ILocation MapToEntity(ILocationModel model, int currentDepth = 1)
 {
     currentDepth++;
     var entity = NameableEntityMapper.MapToEntity<Location, ILocationModel>(model);
     // Location Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance = (Issue)model.FirstIssueAppearance?.MapToEntity();
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.LocationAliases = model.LocationAliases?.Where(i => i.Active).Select(LocationAliasMapperExtensions.MapToEntity).Cast<LocationAlias>().ToList();
     entity.LocationAppearedInIssues = model.LocationAppearedInIssues?.Where(i => i.Active).Select(LocationAppearedInIssueMapperExtensions.MapToEntity).Cast<LocationAppearedInIssue>().ToList();
     entity.LocationIssues = model.LocationIssues?.Where(i => i.Active).Select(LocationIssueMapperExtensions.MapToEntity).Cast<LocationIssue>().ToList();
     entity.LocationMovies = model.LocationMovies?.Where(i => i.Active).Select(LocationMovieMapperExtensions.MapToEntity).Cast<LocationMovie>().ToList();
     entity.LocationStoryArcs = model.LocationStoryArcs?.Where(i => i.Active).Select(LocationStoryArcMapperExtensions.MapToEntity).Cast<LocationStoryArc>().ToList();
     entity.LocationVolumes = model.LocationVolumes?.Where(i => i.Active).Select(LocationVolumeMapperExtensions.MapToEntity).Cast<LocationVolume>().ToList();
     // Return Entity
     return entity;
 }
        public virtual ILocationSearchModel MapToSearchModel(ILocationModel model)
        {
            var searchModel = NameableEntityMapper.MapToSearchModel <ILocationModel, LocationSearchModel>(model);

            // Search Properties
            searchModel.FirstIssueAppearanceId               = model.FirstIssueAppearanceId;
            searchModel.FirstIssueAppearanceCustomKey        = model.FirstIssueAppearance?.CustomKey;
            searchModel.FirstIssueAppearanceApiDetailUrl     = model.FirstIssueAppearance?.ApiDetailUrl;
            searchModel.FirstIssueAppearanceSiteDetailUrl    = model.FirstIssueAppearance?.SiteDetailUrl;
            searchModel.FirstIssueAppearanceName             = model.FirstIssueAppearance?.Name;
            searchModel.FirstIssueAppearanceShortDescription = model.FirstIssueAppearance?.ShortDescription;
            searchModel.FirstIssueAppearanceDescription      = model.FirstIssueAppearance?.Description;
            searchModel.PrimaryImageFileId               = model.PrimaryImageFileId;
            searchModel.PrimaryImageFileCustomKey        = model.PrimaryImageFile?.CustomKey;
            searchModel.PrimaryImageFileApiDetailUrl     = model.PrimaryImageFile?.ApiDetailUrl;
            searchModel.PrimaryImageFileSiteDetailUrl    = model.PrimaryImageFile?.SiteDetailUrl;
            searchModel.PrimaryImageFileName             = model.PrimaryImageFile?.Name;
            searchModel.PrimaryImageFileShortDescription = model.PrimaryImageFile?.ShortDescription;
            searchModel.PrimaryImageFileDescription      = model.PrimaryImageFile?.Description;
            // Return Search Model
            return(searchModel);
        }
        public virtual ILocation MapToEntity(ILocationModel model, int currentDepth = 1)
        {
            currentDepth++;
            var entity = NameableEntityMapper.MapToEntity <Location, ILocationModel>(model);

            // Location Properties
            entity.StartYear = model.StartYear;
            // Related Objects
            entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
            entity.FirstIssueAppearance   = (Issue)model.FirstIssueAppearance?.MapToEntity();
            entity.PrimaryImageFileId     = model.PrimaryImageFileId;
            entity.PrimaryImageFile       = (ImageFile)model.PrimaryImageFile?.MapToEntity();
            // Associated Objects
            entity.LocationAliases          = model.LocationAliases?.Where(i => i.Active).Select(LocationAliasMapperExtensions.MapToEntity).Cast <LocationAlias>().ToList();
            entity.LocationAppearedInIssues = model.LocationAppearedInIssues?.Where(i => i.Active).Select(LocationAppearedInIssueMapperExtensions.MapToEntity).Cast <LocationAppearedInIssue>().ToList();
            entity.LocationIssues           = model.LocationIssues?.Where(i => i.Active).Select(LocationIssueMapperExtensions.MapToEntity).Cast <LocationIssue>().ToList();
            entity.LocationMovies           = model.LocationMovies?.Where(i => i.Active).Select(LocationMovieMapperExtensions.MapToEntity).Cast <LocationMovie>().ToList();
            entity.LocationStoryArcs        = model.LocationStoryArcs?.Where(i => i.Active).Select(LocationStoryArcMapperExtensions.MapToEntity).Cast <LocationStoryArc>().ToList();
            entity.LocationVolumes          = model.LocationVolumes?.Where(i => i.Active).Select(LocationVolumeMapperExtensions.MapToEntity).Cast <LocationVolume>().ToList();
            // Return Entity
            return(entity);
        }
Exemple #27
0
        public void MapExternal(ILocationModel loc, string label = null, MapExternalOptions mapOption = MapExternalOptions.Normal, double zoomLevel = 16)
        {
            if (loc == null)
            {
                throw new ArgumentNullException(nameof(loc));
            }

            PlatformBase.CurrentCore.Analytics.Event("MapExternal-" + mapOption.ToString());

            label = System.Net.WebUtility.HtmlEncode(label ?? loc.LocationDisplayName);
            string url = null;

            switch (mapOption)
            {
            case MapExternalOptions.DrivingDirections:
            {
                url = string.Format("ms-drive-to:?destination.latitude={0}&destination.longitude={1}&destination.name={2}", loc.Latitude.ToString(CultureInfo.InvariantCulture), loc.Longitude.ToString(CultureInfo.InvariantCulture), label);
                var t = Launcher.LaunchUriAsync(new Uri(url));
                break;
            }

            case MapExternalOptions.WalkingDirections:
            {
                url = string.Format("ms-walk-to:?destination.latitude={0}&destination.longitude={1}&destination.name={2}", loc.Latitude.ToString(CultureInfo.InvariantCulture), loc.Longitude.ToString(CultureInfo.InvariantCulture), label);
                var t = Launcher.LaunchUriAsync(new Uri(url));
                break;
            }

            default:
            {
                url = string.Format("bingmaps:?collection=point.{0}_{1}_{2}&lvl={3}", loc.Latitude.ToString(CultureInfo.InvariantCulture), loc.Longitude.ToString(CultureInfo.InvariantCulture), label, zoomLevel.ToString(CultureInfo.InvariantCulture));
                var t = Launcher.LaunchUriAsync(new Uri(url));
                break;
            }
            }
        }
Exemple #28
0
        public async Task <bool> GetScheduledRideLaterRides()
        {
            try
            {
                List <Trip> tripsToRemind = _dbContext.Trips.Where(x => x.Status == TripStatus.Requested && x.IsDeleted == false && x.isScheduled == true && Convert.ToInt32((x.RequestTime - DateTime.UtcNow).TotalMinutes) == 5).ToList();
                foreach (var item in tripsToRemind)
                {
                    Notification notf            = new Notification();
                    var          targetedDevices = _dbContext.UserDevices.Where(x => x.IsDeleted == false && x.User_Id == item.PrimaryUser_Id).ToList();
                    PushNotificationsHelper.SendAndroidPushNotifications(Message: "You have a scheduled ride that is going to start after 5 minutes.", Title: "Korsa", DeviceTokens: targetedDevices.Where(x1 => x1.Platform == true & x1.IsActive == true).Select(a => a.AuthToken).ToList());
                    PushNotificationsHelper.SendIOSPushNotifications(Message: "You have a scheduled ride that is going to start after 5 minutes.", Title: "Korsa", DeviceTokens: targetedDevices.Where(x1 => x1.Platform == false & x1.IsActive == true).Select(a => a.AuthToken).ToList());
                    _dbContext.Notifications.Add(notf);
                }

                List <Trip> tripsToStart = _dbContext.Trips.Include(x => x.PrimaryUser).Where(x => x.Status == TripStatus.Requested && x.IsDeleted == false && x.isScheduled == true && Convert.ToInt32((x.RequestTime - DateTime.UtcNow).TotalMinutes) >= 0).ToList();
                foreach (var item in tripsToStart)
                {
                    Loc    location = Mapper.Map <Location, Loc>(item.PickupLocation);
                    string gender   = "1";
                    bool   isCash   = false;
                    if (item.PrimaryUser.Gender == Gender.Female)
                    {
                        gender = (item.PrimaryUser.DriverPreference == Gender.Female) ? "0" : "2";
                    }
                    if (item.PrimaryUser.PrefferedPaymentMethod == PaymentMethods.Cash)
                    {
                        isCash = (item.PrimaryUser.PrefferedPaymentMethod == PaymentMethods.Cash) ? true : false;
                    }
                    IUserModel userdata = new IUserModel {
                        userId = item.PrimaryUser_Id.Value, userName = item.PrimaryUser.UserName, rating = item.PrimaryUser.Rating, userType = 0
                    };
                    ILocationModel payload = new ILocationModel {
                        latitude = item.PickupLocation.Latitude, longitude = item.PickupLocation.Longitude, dropoflatitude = item.DestinationLocation.Latitude, dropoflongitude = item.DestinationLocation.Longitude, channel = "io:startridenow", locationType = 2, orderid = item.Id, direction = 0, distance = 1000, numberofdrivers = 10000, price = item.EstimatedFare, pickupLocationTitle = item.PickupLocationName, dropofLocationTitle = item.DestinationLocationName, vehicalType = item.RideType_Id, gender = gender, isCash = isCash
                    };
                    payload.userData = userdata;
                    string json        = JsonConvert.SerializeObject(payload);
                    var    httpContent = new StringContent(json);
                    using (var httpClient = new HttpClient())
                    {
                        MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/json");
                        httpClient.DefaultRequestHeaders.Accept.Add(contentType);
                        var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
                        var httpResponse  = httpClient.PostAsync(AppSettingsProvider.RideLaterService, stringContent).Result;

                        if (httpResponse.Content != null)
                        {
                            var responseContent = await httpResponse.Content.ReadAsStringAsync();

                            if (httpResponse.IsSuccessStatusCode)
                            {
                                _dbContext.SaveChanges();
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void Remove(ILocationModel locationModell)
 {
     throw new NotImplementedException();
 }
 public void Update(ILocationModel locationModel)
 {
     throw new NotImplementedException();
 }
 public static ILocationSearchModel MapToSearchModel(this ILocationModel model)
 {
     return(Mapper.MapToSearchModel(model));
 }
 public static bool AreEqual(this ILocationModel model, ILocation entity)
 {
     return(Mapper.AreEqual(model, entity));
 }
 public static ILocation MapToEntity(this ILocationModel model, int currentDepth = 1)
 {
     return(Mapper.MapToEntity(model, currentDepth));
 }
 public static void MapToEntity(this ILocationModel model, ref ILocation entity, int currentDepth = 1)
 {
     Mapper.MapToEntity(model, ref entity, currentDepth);
 }
 public ILocationModel Update(ILocationModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Find existing entity
     // ReSharper disable once PossibleInvalidOperationException
     var existingEntity = LocationsRepository.Get(model.Id.Value);
     // Check if we would be applying identical information, if we are, just return the original
     // ReSharper disable once SuspiciousTypeConversion.Global
     if (LocationMapper.AreEqual(model, existingEntity))
     {
         return LocationMapper.MapToModel(existingEntity);
     }
     // Map model to an existing entity
     LocationMapper.MapToEntity(model, ref existingEntity);
     existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
     // Update it
     LocationsRepository.Update(LocationMapper.MapToEntity(model));
     // Try to Save Changes
     LocationsRepository.SaveChanges();
     // Return the new value
     return Get(existingEntity.Id);
 }
Exemple #36
0
 public void ValidateModelDataAnnotations(ILocationModel locationModel)
 {
     this.modelDataAnnotationCheck.ValidateModelDataAnnotations(locationModel);
 }
 public virtual ILocationSearchModel MapToSearchModel(ILocationModel model)
 {
     var searchModel = NameableEntityMapper.MapToSearchModel<ILocationModel, LocationSearchModel>(model);
     // Search Properties
     searchModel.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     searchModel.FirstIssueAppearanceCustomKey = model.FirstIssueAppearance?.CustomKey;
     searchModel.FirstIssueAppearanceApiDetailUrl = model.FirstIssueAppearance?.ApiDetailUrl;
     searchModel.FirstIssueAppearanceSiteDetailUrl = model.FirstIssueAppearance?.SiteDetailUrl;
     searchModel.FirstIssueAppearanceName = model.FirstIssueAppearance?.Name;
     searchModel.FirstIssueAppearanceShortDescription = model.FirstIssueAppearance?.ShortDescription;
     searchModel.FirstIssueAppearanceDescription = model.FirstIssueAppearance?.Description;
     searchModel.PrimaryImageFileId = model.PrimaryImageFileId;
     searchModel.PrimaryImageFileCustomKey = model.PrimaryImageFile?.CustomKey;
     searchModel.PrimaryImageFileApiDetailUrl = model.PrimaryImageFile?.ApiDetailUrl;
     searchModel.PrimaryImageFileSiteDetailUrl = model.PrimaryImageFile?.SiteDetailUrl;
     searchModel.PrimaryImageFileName = model.PrimaryImageFile?.Name;
     searchModel.PrimaryImageFileShortDescription = model.PrimaryImageFile?.ShortDescription;
     searchModel.PrimaryImageFileDescription = model.PrimaryImageFile?.Description;
     // Return Search Model
     return searchModel;
 }
 public LocationController(ILocationModel locationModel, ILoggerManager logger, IOptions <Sheev.Common.Models.MongoDbSetting> mongoDbSettings, IOptions <Sheev.Common.Models.ApiUrlSetting> apiSettings)
 {
     _context       = new Models.ContextModel(mongoDbSettings, apiSettings, logger);
     _locationModel = locationModel;
 }
 /// <summary>
 /// Sets the distance away property of this object calculated from the specified location object.
 /// </summary>
 /// <param name="loc">Location object to calculate distance away with.</param>
 public void SetDistanceAway(ILocationModel loc)
 {
     this.DistanceAway = this.GetDistanceTo(loc);
 }