/// <summary>
        /// The convert website category.
        /// </summary>
        /// <param name="category">
        /// The category.
        /// </param>
        /// <returns>
        /// The <see cref="CrimeCategory"/>.
        /// </returns>
        private static ProviderServiceCategory ConvertWebsiteCategory(Category category)
        {
            var databaseCategory = new ProviderServiceCategory {
                Description = category.Description, Name = category.Name, Active = true
            };

            return(databaseCategory);
        }
Exemple #2
0
        /// <summary>
        /// The convert database categories.
        /// </summary>
        /// <param name="databaseCategory">
        /// The database categories.
        /// </param>
        /// <returns>
        /// The <see cref="CreateCategories"/>.
        /// </returns>
        public Category ConvertDatabaseCategory(ProviderServiceCategory databaseCategory)
        {
            var category = new Category
            {
                Id          = databaseCategory.ID,
                Name        = databaseCategory.Name,
                Description = databaseCategory.Description
            };

            return(category);
        }
Exemple #3
0
        /// <summary>
        /// The update category.
        /// </summary>
        /// <param name="category">
        /// The category.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool UpdateCategory(ProviderServiceCategory category)
        {
            try
            {
                this.db.Entry(category).State = EntityState.Modified;
                this.db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemple #4
0
        public void MyTestInitialize()
        {
            this.target = new CategoriesLogic();

            this.websiteCategory = new CategoryEditor
            {
                Active        = true,
                Crime         = true,
                Description   = "Test Cat",
                Id            = 1,
                Name          = "Edit Cat",
                CategoryTypes = new List <int> {
                    1
                },
                State = ObjectStatus.ObjectState.Read
            };

            this.databaseCategory = new ProviderServiceCategory
            {
                Active        = true,
                Crime         = false,
                Description   = "Test Cat",
                ID            = 1,
                CategoryTypes = new List <CategoryType> {
                    new CategoryType
                    {
                        ID            = 1,
                        CategoryId    = 1,
                        ServiceTypeId = 1,
                        ServiceType   = new ServiceType {
                            ID = 1, Name = "General"
                        }
                    }
                },
                Name = "Edit Cat",
            };

            this.categoryList = new List <CategoryEditor> {
                this.websiteCategory
            };
        }
        public void MyTestInitialize()
        {
            this.target = new DataLogics();

            this.websiteCountry = new WebsiteCountry {
                Abbreviation = "OH", FullName = "Ohio", Id = 1
            };
            this.websiteState = new WebsiteState {
                Id = 1, Name = "OH"
            };
            this.websiteCounty = new WebsiteCounty {
                Id = 1, Name = "test"
            };
            this.websiteCategory = new ProviderServiceCategory
            {
                Active      = true,
                Name        = "Test",
                ID          = 1,
                Description = "this is a test",
                Crime       = false
            };
        }
        public void MyTestInitialize()
        {
            this.target = new ServiceTypesLogics();

            this.providerServiceCategory1 = new ProviderServiceCategory
            {
                Active      = true,
                Crime       = true,
                Description = "Service Description",
                ID          = 1,
                Name        = "Test 1"
            };
            this.providerServiceCategory2 = new ProviderServiceCategory
            {
                Active      = true,
                Crime       = true,
                Description = "Service Description",
                ID          = 2,
                Name        = "Test 2"
            };
            this.providerServiceCategoryList = new List <ProviderServiceCategory>
            {
                this.providerServiceCategory1,
                this.providerServiceCategory2
            };
            this.categoryTest = new Category {
                Description = "Service Description", Name = "Test 1", Id = 1
            };
            this.serviceType1 = new ServiceType {
                Description = "Test Type 1", ID = 1, Name = "Type 1"
            };
            this.serviceType2 = new ServiceType {
                Description = "Test Type 2", ID = 2, Name = "Type 2"
            };

            this.serviceTypeList = new List <ServiceType> {
                this.serviceType1, this.serviceType2
            };
        }
Exemple #7
0
        /// <summary>
        /// The create category.
        /// </summary>
        /// <param name="category">
        /// The category.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool CreateCategory(ProviderServiceCategory category)
        {
            try
            {
                this.db.ProviderServiceCategories.Add(category);
                this.db.SaveChanges();


                foreach (var categoryType in category.CategoryTypes)
                {
                    categoryType.ID = category.ID;
                    this.db.CategoryTypes.Add(categoryType);
                }

                this.db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemple #8
0
        /// <summary>
        /// Merge database and edit categories.
        /// </summary>
        /// <param name="categoryEditor">
        /// The category editor.
        /// </param>
        /// <param name="databaseCategory">
        /// The database category.
        /// </param>
        /// <returns>
        /// The <see cref="ProviderServiceCategory"/>.
        /// </returns>
        public ProviderServiceCategory MergeCategories(CategoryEditor categoryEditor, ProviderServiceCategory databaseCategory)
        {
            databaseCategory.Active        = categoryEditor.Active;
            databaseCategory.Crime         = categoryEditor.Crime;
            databaseCategory.Description   = categoryEditor.Description;
            databaseCategory.Name          = categoryEditor.Name;
            databaseCategory.CategoryTypes = new List <CategoryType>();
            foreach (var categoryId in categoryEditor.CategoryTypes)
            {
                var foundCategory = databaseCategory.CategoryTypes.Where(categoryType => categoryType.ServiceType != null && categoryType.ServiceType.ID == categoryId).ToList();
                if (foundCategory.Count == 0 || foundCategory[0].ID == 0)
                {
                    databaseCategory.CategoryTypes.Add(new CategoryType
                    {
                        CategoryId    = categoryEditor.Id,
                        ServiceTypeId = categoryId
                    });
                }
            }

            return(databaseCategory);
        }