/// <summary> /// Initializes a new instance of the <see cref="RouteDestinationVM"/> class. /// </summary> /// <param name="routeDestination">The route destination.</param> public RouteDestinationVM(RouteDestination routeDestination) { RouteDestination = routeDestination; if (routeDestination == null) return; //Initialize the ContactInfoVMs UpdateContactInfoVMs(); //Whenever the Client/Location/DetailsLoaded property changes update the VMs _destinationDisposable = RouteDestination.FromAnyPropertyChanged().WhereNotNull() .Where(p => p.PropertyName == "DetailsLoaded" || p.PropertyName == "Client" || p.PropertyName == "Location") .Subscribe(_ => UpdateContactInfoVMs()); }
/// <summary> /// Deletes the route destination. It does not delete the route tasks. /// </summary> /// <param name="routeDestination">The route destination to delete.</param> public void DeleteRouteDestination(RouteDestination routeDestination) { this.ObjectContext.DetachExistingAndAttach(routeDestination); routeDestination.RouteTasks.Load(); if (routeDestination.RouteTasks.Any()) routeDestination.RouteTasks.Clear(); this.ObjectContext.RouteDestinations.DeleteObject(routeDestination); }
public void UpdateRouteDestination(RouteDestination currentRouteDestination) { currentRouteDestination.LastModified = DateTime.UtcNow; currentRouteDestination.LastModifyingUserId = CurrentUserAccount().Id; this.ObjectContext.RouteDestinations.AttachAsModified(currentRouteDestination); }
public void InsertRouteDestination(RouteDestination routeDestination) { if ((routeDestination.EntityState != EntityState.Detached)) this.ObjectContext.ObjectStateManager.ChangeObjectState(routeDestination, EntityState.Added); else this.ObjectContext.RouteDestinations.AddObject(routeDestination); }
/// <summary> /// Create a new RouteDestination object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="orderInRoute">Initial value of the OrderInRoute property.</param> /// <param name="routeId">Initial value of the RouteId property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> public static RouteDestination CreateRouteDestination(global::System.Guid id, global::System.Int32 orderInRoute, global::System.Guid routeId, global::System.DateTime createdDate) { RouteDestination routeDestination = new RouteDestination(); routeDestination.Id = id; routeDestination.OrderInRoute = orderInRoute; routeDestination.RouteId = routeId; routeDestination.CreatedDate = createdDate; return routeDestination; }
/// <summary> /// Deprecated Method for adding a new object to the RouteDestinations EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRouteDestinations(RouteDestination routeDestination) { base.AddObject("RouteDestinations", routeDestination); }
/// <summary> /// Adds the draggedItem to either the Route or RouteDestination it was dragged to. /// </summary> /// <param name="routeTask">The route task.</param> /// <param name="destination">The destination.</param> /// <param name="placeInRoute">The place in route.</param> /// <param name="dropPlacement"> </param> public static void AddRouteTaskToDestinationOrRoute(RouteTask routeTask, object destination, int placeInRoute, DropPlacement dropPlacement) { //If the user drops the task on a destination, just add it to the end of its list of RouteTasks if ((destination is RouteDestination) && dropPlacement == DropPlacement.In) { ((RouteDestination)destination).RouteTasksListWrapper.Add(routeTask); //TODO:add analytic //No need to do any of the other logic below, skip to the next iteration of the loop return; } routeTask.RemoveRouteDestination(); //Create new destination var newDestination = new RouteDestination { Id = Guid.NewGuid(), LocationId = routeTask.LocationId, ClientId = routeTask.ClientId }; //Add the tasks to the destination newDestination.RouteTasks.Add(routeTask); if (destination is RouteDestination) { //Get the Destinations, Route var route = ((RouteDestination)destination).Route; //Add the new destination to the Route route.RouteDestinationsListWrapper.Insert(placeInRoute, newDestination); //TODO:add analytic } if (destination is Route) { //Add the new destination to the Route ((Route)destination).RouteDestinationsListWrapper.Insert(placeInRoute, newDestination); //TODO:add analytic } }