コード例 #1
0
ファイル: Service.cs プロジェクト: FoundOPS/server
        /// <summary>
        /// Converts from the FoundOPS model to the API model
        /// </summary>
        /// <param name="serviceModel">The service to convert</param>
        /// <returns>A Service that has been converted to it's API model</returns>
        public static Service ConvertModel(FoundOps.Core.Models.CoreEntities.Service serviceModel)
        {
            //Create the new service and set its properties
            var service = new Service
            {
                Id = serviceModel.Id,
                CreatedDate = serviceModel.CreatedDate,
                Name = serviceModel.ServiceTemplate.Name,
                ServiceDate = serviceModel.ServiceDate,
                ClientId = serviceModel.ClientId,
                Client = serviceModel.Client != null ? Client.ConvertModel(serviceModel.Client) : null,
                ServiceProviderId = serviceModel.ServiceProviderId,
                RecurringServiceId = serviceModel.RecurringServiceId
            };

            service.SetLastModified(serviceModel.LastModified, serviceModel.LastModifyingUserId);

            if (serviceModel.RecurringServiceParent != null && serviceModel.RecurringServiceParent.Repeat != null)
                service.Repeat = Repeat.ConvertModel(serviceModel.RecurringServiceParent.Repeat);

            //Convert each field from the FoundOPS model to the API model
            //Add the newly converted field to the newly created service
            foreach (var field in serviceModel.ServiceTemplate.Fields.OrderBy(f => f.Name))
                service.Fields.Add(Field.ConvertModel(field));

            service.ParentServiceTemplateId = serviceModel.ServiceTemplate.OwnerServiceTemplateId;

            return service;
        }
コード例 #2
0
ファイル: ContactInfo.cs プロジェクト: FoundOPS/server
        public static ContactInfo Convert(FoundOps.Core.Models.CoreEntities.ContactInfo contactInfoModel)
        {
            var contactInfo = new ContactInfo
                {
                    Id = contactInfoModel.Id,
                    CreatedDate = contactInfoModel.CreatedDate,
                    Type = contactInfoModel.Type,
                    Label = contactInfoModel.Label,
                    Data = contactInfoModel.Data,
                    ClientId = contactInfoModel.ClientId,
                    LocationId = contactInfoModel.LocationId
                };

            contactInfo.SetLastModified(contactInfoModel.LastModified, contactInfoModel.LastModifyingUserId);

            //TODO Generalize this everywhere
            if (string.IsNullOrEmpty(contactInfo.Type))
                contactInfo.Type = "";
            if (string.IsNullOrEmpty(contactInfo.Label))
                contactInfo.Label = "";
            if (string.IsNullOrEmpty(contactInfo.Data))
                contactInfo.Data = "";

            return contactInfo;
        }
コード例 #3
0
ファイル: ServiceTemplate.cs プロジェクト: FoundOPS/server
        /// <summary>
        /// Converts from the FoundOPS model to the API model
        /// </summary>
        public static ServiceTemplate ConvertModel(FoundOps.Core.Models.CoreEntities.ServiceTemplate model)
        {
            var serviceType = new ServiceTemplate
            {
                Id = model.Id,
                Name = model.Name
            };

            return serviceType;
        }
コード例 #4
0
ファイル: Repeat.cs プロジェクト: FoundOPS/server
        public static Repeat ConvertModel(FoundOps.Core.Models.CoreEntities.Repeat repeatModel)
        {
            var repeat = new Api.Models.Repeat
            {
                Id = repeatModel.Id,
                StartDate = repeatModel.StartDate,
                EndDate = repeatModel.EndDate,
                EndAfterTimes = repeatModel.EndAfterTimes,
                RepeatEveryTimes = repeatModel.RepeatEveryTimes,
                FrequencyInt = repeatModel.FrequencyInt,
                FrequencyDetailInt = repeatModel.FrequencyDetailInt
            };

            return repeat;
        }
コード例 #5
0
ファイル: Client.cs プロジェクト: FoundOPS/server
        public static Client ConvertModel(FoundOps.Core.Models.CoreEntities.Client clientModel)
        {
            var client = new Client
            {
                Id = clientModel.Id,
                CreatedDate = clientModel.CreatedDate,
                Name = clientModel.Name
            };

            client.SetLastModified(clientModel.LastModified, clientModel.LastModifyingUserId);

            foreach (var contactInfo in clientModel.ContactInfoSet)
                client.ContactInfoSet.Add(ContactInfo.Convert(contactInfo));

            return client;
        }
コード例 #6
0
ファイル: Route.cs プロジェクト: FoundOPS/server
        /// <summary>
        /// Converts the model.
        /// </summary>
        /// <param name="routeModel">The route model.</param>
        /// <returns>The corresponding API model for Route.</returns>
        public static Route ConvertModel(FoundOps.Core.Models.CoreEntities.Route routeModel)
        {
            var route = new Route
                {
                    Id = routeModel.Id,
                    CreatedDate = routeModel.CreatedDate,
                    Name = routeModel.Name,
                    BusinessAccountId = routeModel.OwnerBusinessAccountId
                };

            route.SetLastModified(routeModel.LastModified, routeModel.LastModifyingUserId);

            foreach (var routeDestinationModel in routeModel.RouteDestinations.OrderBy(rd => rd.OrderInRoute))
                route.RouteDestinations.Add(RouteDestination.ConvertModel(routeDestinationModel));

            return route;
        }
コード例 #7
0
ファイル: TaskStatus.cs プロジェクト: FoundOPS/server
        public static TaskStatus ConvertModel(FoundOps.Core.Models.CoreEntities.TaskStatus model)
        {
            var status = new TaskStatus
            {
                Id = model.Id,
                CreatedDate = model.CreatedDate,
                Name = model.Name,
                Color = model.Color,
                DefaultTypeInt = model.DefaultTypeInt,
                RemoveFromRoute = model.RemoveFromRoute,
                BusinessAccountId = model.BusinessAccountId
            };

            status.SetLastModified(model.LastModified, model.LastModifyingUserId);

            return status;
        }
コード例 #8
0
ファイル: RouteTask.cs プロジェクト: FoundOPS/server
        public static RouteTask ConvertModel(FoundOps.Core.Models.CoreEntities.RouteTask routeTaskModel)
        {
            var routeTask = new RouteTask
                {
                    Id = routeTaskModel.Id, 
                    CreatedDate = routeTaskModel.CreatedDate,
                    Name = routeTaskModel.Name, 
                    Date = routeTaskModel.Date, 
                    RecurringServiceId = routeTaskModel.RecurringServiceId, 
                    ServiceId = routeTaskModel.ServiceId, 
                    TaskStatusId = routeTaskModel.TaskStatusId
                };

            routeTask.SetLastModified(routeTaskModel.LastModified, routeTaskModel.LastModifyingUserId);

            return routeTask;
        }
コード例 #9
0
ファイル: RouteDestination.cs プロジェクト: FoundOPS/server
        public static RouteDestination ConvertModel(FoundOps.Core.Models.CoreEntities.RouteDestination routeDestinationModel)
        {
            var routeDestination = new RouteDestination
                {
                    Id = routeDestinationModel.Id, 
                    CreatedDate = routeDestinationModel.CreatedDate,
                    OrderInRoute = routeDestinationModel.OrderInRoute
                };

            routeDestination.SetLastModified(routeDestinationModel.LastModified, routeDestinationModel.LastModifyingUserId);

            foreach (var routeTaskModel in routeDestinationModel.RouteTasks.OrderBy(rt => rt.Name))
                routeDestination.RouteTasks.Add(RouteTask.ConvertModel(routeTaskModel));

            if (routeDestinationModel.Client != null)
                routeDestination.Client = Client.ConvertModel(routeDestinationModel.Client);

            if (routeDestinationModel.Location != null)
                routeDestination.Location = Location.ConvertModel(routeDestinationModel.Location);

            return routeDestination;
        }
コード例 #10
0
ファイル: Location.cs プロジェクト: FoundOPS/server
        public static Location ConvertGeocode(FoundOps.Common.NET.GeocoderResult geocoderResult)
        {
            Decimal tempLatLong = 0;

            Decimal.TryParse(geocoderResult.Latitude, out tempLatLong);
            var latitude = tempLatLong == 0 ? (decimal?)null : tempLatLong;

            Decimal.TryParse(geocoderResult.Longitude, out tempLatLong);
            var longitude = tempLatLong == 0 ? (decimal?)null : tempLatLong;

            var location = new Location
            {
                Id = Guid.NewGuid(),
                AddressLineOne = geocoderResult.AddressLineOne,
                AddressLineTwo = geocoderResult.AddressLineTwo,
                AdminDistrictTwo = geocoderResult.City,
                AdminDistrictOne = geocoderResult.State,
                CountryCode = geocoderResult.CountryCode,
                PostalCode = geocoderResult.ZipCode,
                Latitude = latitude != null ? Decimal.Round((decimal) latitude, 8).ToString() : String.Empty,
                Longitude = longitude != null ? Decimal.Round((decimal) longitude, 8).ToString() : String.Empty,
                IsNew = true
            };

            if (location.CountryCode == "United States")
                location.CountryCode = "US";

            return location;
        }
コード例 #11
0
ファイル: Repeat.xaml.cs プロジェクト: FoundOPS/server
        private void SetupControl(FoundOps.Core.Models.CoreEntities.Repeat schedule)
        {
            var monthlyFrequencyDetailsStackPanel = new StackPanel();

            if (schedule == null || schedule.AvailableMonthlyFrequencyDetailTypes == null)
            {
                this.Content = null;
                this.InvalidateArrange();
                return;
            }

            foreach (var monthlyFrequencyDetail in schedule.AvailableMonthlyFrequencyDetailTypes)
            {
                var monthlyFrequencyDetailRadioButton = new RadioButton { GroupName = "RepeatOn" };

                monthlyFrequencyDetailRadioButton.SetBinding(ContentControl.ContentProperty,
                                                             new Binding("StartDate")
                                                                 {
                                                                     Source = schedule,
                                                                     Converter =
                                                                         new MonthlyFrequencyDetailToStringConverter(
                                                                         monthlyFrequencyDetail)
                                                                 });

                monthlyFrequencyDetailRadioButton.SetBinding(ToggleButton.IsCheckedProperty,
                                                             new Binding("FrequencyDetailAsMonthlyFrequencyDetail")
                                                                 {
                                                                     Source = schedule,
                                                                     Converter =
                                                                         new MonthlyFrequencyDetailIsCheckedConverter(
                                                                         monthlyFrequencyDetail)
                                                                 });

                var detail = monthlyFrequencyDetail;
                monthlyFrequencyDetailRadioButton.Checked += (o, args) =>
                                                                 {
                                                                     Value.FrequencyDetailAsMonthlyFrequencyDetail = detail;
                                                                 };

                monthlyFrequencyDetailsStackPanel.Children.Add(monthlyFrequencyDetailRadioButton);
            }

            this.Content = monthlyFrequencyDetailsStackPanel;
            this.InvalidateArrange();
        }