예제 #1
0
        public RouteViewModel MapDetailsDomainToViewModel(int id)
        {
            var returnViewModel = new RouteViewModel();

            var domainRoute = _routeService.GetRoute(id);

            returnViewModel = BuildRouteViewModelFromDomain(domainRoute);

            return returnViewModel;
        }
예제 #2
0
        private RouteViewModel BuildRouteViewModelFromDomain(DodgingBranches.Models.Route route)
        {
            var returnRoute = new RouteViewModel();

            returnRoute.Name = route.Name;
            returnRoute.Id = route.RouteId;
            returnRoute.StartPoint = new RouteMapPoint { Latitude = route.StartPoint.Latitude, Longitude = route.StartPoint.Longitude } ;
            returnRoute.EndPoint = new RouteMapPoint { Latitude = route.EndPoint.Latitude, Longitude = route.EndPoint.Longitude };
            returnRoute.EnteredBy = route.UserId;

            if (route.Comments != null)
            {
                returnRoute.Comments = route.Comments.Select(x => new Models.Comment
                {
                    Id = x.CommentId,
                    CommentText = x.CommentText,
                    DateEntered = x.DateEntered,
                    ParentCommentId = x.ParentCommentId,
                    RouteId = x.RouteId,
                    UserId = x.UserId
                }).ToList();
            }

            returnRoute.DateEntered = route.DateEntered;
            returnRoute.Description = route.Description;
            returnRoute.StartLocation = new Models.AddressViewModel
            {
                AddressLine1 = route.StartLocation.Address1,
                City = route.StartLocation.City,
                AddressId = route.StartLocation.AddressId,
                State = route.StartLocation.State,
                ZipCode = route.StartLocation.ZipCode
            };

            returnRoute.EndLocation = new Models.AddressViewModel
            {
                AddressLine1 = route.EndLocation.Address1,
                City = route.EndLocation.City,
                AddressId = route.EndLocation.AddressId,
                State = route.EndLocation.State,
                ZipCode = route.EndLocation.ZipCode
            };

            if (route.Tags != null)
            {
                returnRoute.Tags = route.Tags.Select(x => new Models.TagViewModel
                {
                    Id = x.TagId,
                    TagName = x.TagText
                }).ToList();
            }

            return returnRoute;
        }