Ejemplo n.º 1
0
        public int SubAddIndustryCategory(IndustrySubCatModel subcategoryModel)
        {
            int SubCategoryId = 0;

            try
            {
                SubCategoryId = (from sub in DatabaseConnection.IndustrySubCategories
                                 where sub.SubCategoryName.ToLower() == subcategoryModel.SubCategoryName.ToLower()
                                 select sub.Id).FirstOrDefault();
                if (SubCategoryId == 0)
                {
                    DatabaseConnection.IndustrySubCategories.Add(new WorldRef.IndustrySubCategory()
                    {
                        IndustryId      = subcategoryModel.IndustryId,
                        IndusCategoryId = subcategoryModel.CategoryId,
                        SubCategoryName = subcategoryModel.SubCategoryName,
                        createdon       = DateTime.Now
                    });

                    DatabaseConnection.SaveChanges();

                    SubCategoryId = (from sub in DatabaseConnection.IndustrySubCategories
                                     where sub.SubCategoryName.ToLower() == subcategoryModel.SubCategoryName.ToLower()
                                     select sub.Id).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                SubCategoryId = 0;
                new KnowledgeException(ex.Message);
            }
            return(SubCategoryId);
        }
        public int SubAddIndustryCategory(IndustrySubCatModel subcategoryModel)
        {
            int SubCategoryId = 0;
            try
            {
                SubCategoryId = (from sub in DatabaseConnection.IndustrySubCategories
                                 where sub.SubCategoryName.ToLower() == subcategoryModel.SubCategoryName.ToLower()
                                 select sub.Id).FirstOrDefault();
                if (SubCategoryId == 0)
                {
                    DatabaseConnection.IndustrySubCategories.Add(new WorldRef.IndustrySubCategory()
                    {
                        IndustryId = subcategoryModel.IndustryId,
                        IndusCategoryId = subcategoryModel.CategoryId,
                        SubCategoryName = subcategoryModel.SubCategoryName,
                        createdon = DateTime.Now

                    });

                    DatabaseConnection.SaveChanges();

                    SubCategoryId = (from sub in DatabaseConnection.IndustrySubCategories
                                     where sub.SubCategoryName.ToLower() == subcategoryModel.SubCategoryName.ToLower()
                                     select sub.Id).FirstOrDefault();
                }

            }
            catch (Exception ex)
            {
                SubCategoryId = 0;
                new KnowledgeException(ex.Message);
            }
            return SubCategoryId;
        }