Exemplo n.º 1
0
        public override int GetHashCode()
        {
            int hash = Title.GetHashCode();

            hash ^= Text.GetHashCode();
            hash ^= Level.GetHashCode();
            if (Image != null)
            {
                hash ^= Image.GetHashCode();
            }
            hash ^= CategoryId.GetHashCode();
            hash ^= Faction.GetHashCode();
            hash ^= IsHidden.GetHashCode();
            if (ClassRestricted)
            {
                foreach (var x in Classes)
                {
                    hash ^= x.Fqn.GetHashCode();
                }
            }
            if (HasPlanets)
            {
                foreach (var x in Planets)
                {
                    hash ^= x.Id.GetHashCode();
                }
            }
            return(hash);
        }
Exemplo n.º 2
0
        private void FillDropDown()
        {
            ItemRelationship.DisplayCategoryHierarchy(cboCategories, -1, PortalId, false);

            var li = new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1");

            cboCategories.Items.Insert(0, li);

            li = cboCategories.Items.FindByValue(CategoryId.ToString(CultureInfo.InvariantCulture));
            if (li != null)
            {
                li.Selected = true;
            }

            cboWorkflow.Visible = UseApprovals;
            lblWorkflow.Visible = UseApprovals;
            if (UseApprovals)
            {
                cboWorkflow.DataSource     = DataProvider.Instance().GetApprovalStatusTypes(PortalId);
                cboWorkflow.DataValueField = "ApprovalStatusID";
                cboWorkflow.DataTextField  = "ApprovalStatusName";
                cboWorkflow.DataBind();
                li = cboWorkflow.Items.FindByText(ApprovalStatus.Waiting.Name);
                if (li != null)
                {
                    li.Selected = true;
                }
            }
        }
Exemplo n.º 3
0
 public bool Equals(Product other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(base.Equals(other) &&
            string.Equals(Name, other.Name) &&
            string.Equals(BarCode, other.BarCode) &&
            Price == other.Price &&
            string.Equals(Description, other.Description) &&
            IsPublished == other.IsPublished &&
            Equals(Dimensions, other.Dimensions) &&
            ManufacturerId.Equals(other.ManufacturerId) &&
            Equals(Pictures, other.Pictures) &&
            CategoryId.Equals(other.CategoryId) &&
            Equals(Category, other.Category) &&
            ProductTypeId == other.ProductTypeId &&
            Equals(ProductType, other.ProductType) &&
            string.Equals(ExternalSourceName, other.ExternalSourceName) &&
            string.Equals(ExternalId, other.ExternalId));
 }
Exemplo n.º 4
0
        public void MapNullProperties()
        {
            const int    CategoryId   = 1;
            const string CategoryName = null;

            DocumentMapperConfig.NewConfig <Category>()
            .WithId(c => c.Id)
            .WithAttribute(c => c.Name);

            var category = new Category
            {
                Id   = CategoryId,
                Name = CategoryName
            };


            var document = category.ToDocument();


            var resource = (Resource)document.Data;

            resource.Id.Should().Be(CategoryId.ToString());
            resource.Attributes.Should().ContainKey(nameof(Category.Name));
            resource.Attributes[nameof(Category.Name)].Should().Be(CategoryName);
        }
Exemplo n.º 5
0
 public SPDiagnosticsCategory this[CategoryId id]
 {
     get
     {
         return(Areas[DiagnosticsAreaName].Categories[id.ToString()]);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (CategoryId != null)
         {
             hashCode = hashCode * 59 + CategoryId.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Info != null)
         {
             hashCode = hashCode * 59 + Info.GetHashCode();
         }
         if (CategoryItems != null)
         {
             hashCode = hashCode * 59 + CategoryItems.GetHashCode();
         }
         if (Buy != null)
         {
             hashCode = hashCode * 59 + Buy.GetHashCode();
         }
         if (Sell != null)
         {
             hashCode = hashCode * 59 + Sell.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 7
0
        public void MapWithDefaultsChangingTypeName()
        {
            const int    CategoryId          = 1;
            const string CategoryName        = "Category1";
            const string CategoryDescription = "Description Category1";
            const string CategoryType        = "CategoryModel";

            DocumentMapperConfig.NewConfig <Category>()
            .WithTypeName(CategoryType)
            .MapWithDetaults();

            var category = new Category
            {
                Id          = CategoryId,
                Name        = CategoryName,
                Description = CategoryDescription
            };


            var document = category.ToDocument();


            var resource = (Resource)document.Data;

            resource.Id.Should().Be(CategoryId.ToString());
            resource.Type.Should().Be(CategoryType);
            resource.Attributes.Should().ContainKey(nameof(Category.Name));
            resource.Attributes[nameof(Category.Name)].Should().Be(CategoryName);
            resource.Attributes.Should().ContainKey(nameof(Category.Description));
            resource.Attributes[nameof(Category.Description)].Should().Be(CategoryDescription);
        }
Exemplo n.º 8
0
        public void MapWithoutIdShouldUseDefaultMapping()
        {
            const int    CategoryId          = 1;
            const string CategoryName        = "Category1";
            const string CategoryDescription = "Description Category1";

            DocumentMapperConfig.NewConfig <Category>()
            .WithAttribute(c => c.Name)
            .WithAttribute(c => c.Description);

            var category = new Category
            {
                Id          = CategoryId,
                Name        = CategoryName,
                Description = CategoryDescription
            };


            var document = category.ToDocument();


            var resource = (Resource)document.Data;

            resource.Id.Should().Be(CategoryId.ToString());
        }
Exemplo n.º 9
0
        public void MapWrapperType()
        {
            const int    CategoryId          = 1;
            const string CategoryName        = "Category1";
            const string CategoryDescription = "Description Category1";

            DocumentMapperConfig.NewConfig <Category>()
            .MapWithDetaults()
            .Ignore(c => c.Description);

            var category = new Category
            {
                Id          = CategoryId,
                Name        = CategoryName,
                Description = CategoryDescription
            };

            var result = new ResultModel <Category>
            {
                Data = category
            };

            DocumentMapperConfig.AddWrapperType(typeof(ResultModel <>), r => r.Data);


            var document = result.ToDocument();


            var resource = (Resource)document.Data;

            resource.Id.Should().Be(CategoryId.ToString());
            resource.Attributes.Should().ContainKey(nameof(Category.Name));
            resource.Attributes[nameof(Category.Name)].Should().Be(CategoryName);
            resource.Attributes.Should().NotContainKey(nameof(Category.Description));
        }
        public void Configure(EntityTypeBuilder <CatalogCategory> builder)
        {
            builder
            .Property(x => x.Id)
            .UsePropertyAccessMode(PropertyAccessMode.Field)
            .HasConversion(x => x.Id, id => CatalogCategoryId.Of(id));

            builder
            .Property(x => x.CatalogId)
            .IsRequired()
            .HasConversion(x => x.Id, id => CatalogId.Of(id));

            builder
            .Property(x => x.CategoryId)
            .IsRequired()
            .HasConversion(x => x.Id, id => CategoryId.Of(id));

            builder
            .HasOne(x => x.Parent)
            .WithMany()
            .HasForeignKey("CatalogCategoryParentId")
            .IsRequired(false);

            builder.Ignore(x => x.IsRoot);
        }
Exemplo n.º 11
0
        public void WhenIProcessTheFile()
        {
            ImageMemoryStream.Seek(0, SeekOrigin.Begin);
            const string classifierConfigFile = "svm_config.xml";

            //Arrange
            var handler = new ImageRatingHandler
            {
                Parameters = new WorkItemBase.WorkItemParameters
                {
                    RuntimeData = new Dictionary <string, string>
                    {
                        { "ExhibitId", ExhibitId.ToString(CultureInfo.InvariantCulture) },
                        { "FileId", FileId.ToString(CultureInfo.InvariantCulture) },
                        { "FileCategoryId", CategoryId.ToString(CultureInfo.InvariantCulture) },
                        { "ClassifierConfigFile", Path.GetFullPath(classifierConfigFile) }
                    }
                },
                WorkItemDataStream = ImageMemoryStream
            };

            //Act
            using (new Performance("ImageRating"))
            {
                HandlerOutcome = handler.Execute();
            }
        }
 public void Configure(EntityTypeBuilder <Category> builder)
 {
     builder
     .Property(x => x.Id)
     .UsePropertyAccessMode(PropertyAccessMode.Field)
     .HasConversion(x => x.Id, id => CategoryId.Of(id));
 }
        /// <summary>
        /// Returns true if CategoryInfoWithProductCountDto instances are equal
        /// </summary>
        /// <param name="other">Instance of CategoryInfoWithProductCountDto to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CategoryInfoWithProductCountDto other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     CategoryId == other.CategoryId ||

                     CategoryId.Equals(other.CategoryId)
                     ) &&
                 (
                     ParentCategoryId == other.ParentCategoryId ||
                     ParentCategoryId != null &&
                     ParentCategoryId.Equals(other.ParentCategoryId)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     ProductCount == other.ProductCount ||

                     ProductCount.Equals(other.ProductCount)
                 ));
        }
Exemplo n.º 14
0
 private void Bind2()
 {
     CategoryId.DataSource     = bllut.GetList("");
     CategoryId.DataTextField  = "typename";
     CategoryId.DataValueField = "typeid";
     CategoryId.DataBind();
 }
Exemplo n.º 15
0
        /// <summary>
        /// Determines whether the specified Object is equal to the current Object.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (Object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }


            var other = (VLLibraryQuestionCategory)obj;

            //reference types
            if (!Object.Equals(Name, other.Name))
            {
                return(false);
            }
            //value types
            if (!CategoryId.Equals(other.CategoryId))
            {
                return(false);
            }
            if (!AttributeFlags.Equals(other.AttributeFlags))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
        public void MapSpecificProperties()
        {
            const int    CategoryId          = 1;
            const string CategoryName        = "Category1";
            const string CategoryDescription = "Description Category1";

            DocumentMapperConfig.NewConfig <Category>()
            .WithId(c => c.Id)
            .WithAttribute(c => c.Name);

            var category = new Category
            {
                Id          = CategoryId,
                Name        = CategoryName,
                Description = CategoryDescription
            };


            var document = category.ToDocument();


            var resource = (Resource)document.Data;

            resource.Id.Should().Be(CategoryId.ToString());
            resource.Attributes.Should().ContainKey(nameof(Category.Name));
            resource.Attributes[nameof(Category.Name)].Should().Be(CategoryName);
            resource.Attributes.Should().NotContainKey(nameof(Category.Description));
        }
Exemplo n.º 17
0
        public void Normalize()
        {
            Keyword    = Keyword.EmptyToNull();
            Sort       = Sort.EmptyToNull();
            SortOrder  = SortOrder.EmptyToNull();
            CatalogId  = CatalogId.EmptyToNull();
            CategoryId = CategoryId.EmptyToNull();
            Sort       = Sort.EmptyToNull();
            Sort       = Sort.EmptyToNull();

            if (!string.IsNullOrEmpty(Keyword))
            {
                Keyword = Keyword.EscapeSearchTerm();
            }

            if (PricelistIds != null)
            {
                PricelistIds = PricelistIds.Where(id => id != null).ToArray();

                if (!PricelistIds.Any())
                {
                    PricelistIds = null;
                }
            }
        }
Exemplo n.º 18
0
        public async Task <ExecutionStatus <Category> > Run(CategoryId categoryId)
        {
            using var connection = new SqliteConnection
                                       (_geekLemonContext.ConnectionString);

            var q = @"SELECT Id, DisplayName, Name,
                WhatWeAreLookingFor,UniqueId ,Version  FROM Categories
                Where Id = @Id";

            try
            {
                var r = await connection.
                        QueryFirstOrDefaultAsync <CategoryTemp>
                            (q, new
                {
                    @Id = categoryId.Value,
                });

                var rmaped = _mapper.Map <Category>(r);

                return(ExecutionStatus <Category> .DbIfDefaultThenError(rmaped));
            }
            catch (Exception ex)
            {
                return(ExecutionStatus <Category> .DbError(ex));
            }
        }
        private bool CategoryIsExisting(IRepositoryFactory repositoryFactory, CategoryId categoryId)
        {
            var repository = repositoryFactory.CreateRepository <Category>();
            var category   = repository.FindOneAsync(x => x.CategoryId == categoryId).GetAwaiter().GetResult();

            return(category != null);
        }
Exemplo n.º 20
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (FullDocumentFileName != null ? FullDocumentFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (FreeSnippetFileName != null ? FreeSnippetFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (OriginalFileName != null ? OriginalFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Degree != null ? Degree.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (CourseName != null ? CourseName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (CourseCode != null ? CourseCode.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Year != null ? Year.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ UniversityId.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ UploadedBy.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ UploadedAt.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (DeletedAt != null ? DeletedAt.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ IsFree.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (IsApproved != null ? IsApproved.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Hash != null ? Hash.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (MinHashSignature != null ? MinHashSignature.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ CategoryId.GetHashCode();
         return(hashCode);
     }
 }
        [U] public void Null()
        {
            CategoryId c = 10;

            (c == null).Should().BeFalse();
            (null == c).Should().BeFalse();
        }
Exemplo n.º 22
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (CategoryId != 0)
            {
                hash ^= CategoryId.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Details.Length != 0)
            {
                hash ^= Details.GetHashCode();
            }
            if (Price != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Price);
            }
            if (StockQuantity != 0)
            {
                hash ^= StockQuantity.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 23
0
        public static void SampleIntValueObject()
        {
            Console.WriteLine("---IntValueObject Sample---");
            var productId      = new ProductId(1);
            var otherProductId = productId;
            var categoryId     = new CategoryId(1);

            Console.WriteLine("var productId = new ProductId(1);");
            Console.WriteLine("var otherProductId = productId;");
            Console.WriteLine("var categoryId = new CategoryId(1);");
            Console.WriteLine();
            Console.WriteLine($"productId: {productId}");
            Console.WriteLine($"productId.Value: {productId.Value}");
            Console.WriteLine();
            Console.WriteLine($"productId == otherProductId: {productId == otherProductId}");
            Console.WriteLine($"productId.Equals(otherProductId): {productId.Equals(otherProductId)}");
            Console.WriteLine($"productId == new ProductId(1): {productId == new ProductId(1)}");
            Console.WriteLine($"productId.Equals(new ProductId(1)): {productId.Equals(new ProductId(1))}");
            Console.WriteLine();
            Console.WriteLine($"productId == new ProductId(2): {productId == new ProductId(2)}");
            Console.WriteLine($"productId.Equals(new ProductId(2)): {productId.Equals(new ProductId(2))}");
            Console.WriteLine($"productId.Equals(null): {productId.Equals(null)}");
            Console.WriteLine($"productId.Equals(1): {productId.Equals(1)}");
            Console.WriteLine();
            Console.WriteLine("productId == categoryId: Compile Error");
            Console.WriteLine($"productId.Equals(categoryId): {productId.Equals(categoryId)}");
            Console.WriteLine("productId == new CategoryId(1):  Compile Error");
            Console.WriteLine($"productId.Equals(new CategoryId(1)): {productId.Equals(new CategoryId(1))}");
            Console.WriteLine();
        }
        public async Task <ExecutionStatus> Run(CategoryId categoryId)
        {
            using var connection = new SqliteConnection(_geekLemonContext.ConnectionString);

            var q = @"DELETE FROM Categories WHERE Id=@Id;";

            try
            {
                var result = await connection.QueryAsync <int>(q,
                                                               new
                {
                    @Id = categoryId.Value
                });
            }
            catch (Exception ex)
            {
                if (ExecutionFlow.Options.ThrowExceptions)
                {
                    throw;
                }

                return(ExecutionStatus.DbError(ex));
            }

            return(ExecutionStatus.DbOk());
        }
Exemplo n.º 25
0
 public static Category GetCategory(CategoryId id   = null, string name           = "name", int level = 0,
                                    string iconPath = "path", CategoryId parentId = null,
                                    IEnumerable <CategoryProperty> categoryProperties = null)
 {
     id = id ?? GetCategoryId(0);
     return(Category.CreateCategory(id, name, level, iconPath, parentId, categoryProperties));
 }
Exemplo n.º 26
0
 public static IDomainEvent GetCreatedEvent(CategoryId id   = null, string name           = "name", int level = 0,
                                            string iconPath = "path", CategoryId parentId = null,
                                            IEnumerable <CategoryProperty> categoryProperties = null)
 {
     id = id ?? GetCategoryId(0);
     return(new CategoryCreated(id, name, level, iconPath, parentId, categoryProperties));
 }
        private bool CategoryMustExist(IRepositoryFactory repositoryFactory, CategoryId categoryId)
        {
            var repository = repositoryFactory.CreateRepository <Category>();
            var category   = repository.FindOneAsync(x => x.CategoryId == categoryId).Result;

            return(category != null);
        }
Exemplo n.º 28
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CatalogItem other &&
                   ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) &&
                   ((Description == null && other.Description == null) || (Description?.Equals(other.Description) == true)) &&
                   ((Abbreviation == null && other.Abbreviation == null) || (Abbreviation?.Equals(other.Abbreviation) == true)) &&
                   ((LabelColor == null && other.LabelColor == null) || (LabelColor?.Equals(other.LabelColor) == true)) &&
                   ((AvailableOnline == null && other.AvailableOnline == null) || (AvailableOnline?.Equals(other.AvailableOnline) == true)) &&
                   ((AvailableForPickup == null && other.AvailableForPickup == null) || (AvailableForPickup?.Equals(other.AvailableForPickup) == true)) &&
                   ((AvailableElectronically == null && other.AvailableElectronically == null) || (AvailableElectronically?.Equals(other.AvailableElectronically) == true)) &&
                   ((CategoryId == null && other.CategoryId == null) || (CategoryId?.Equals(other.CategoryId) == true)) &&
                   ((TaxIds == null && other.TaxIds == null) || (TaxIds?.Equals(other.TaxIds) == true)) &&
                   ((ModifierListInfo == null && other.ModifierListInfo == null) || (ModifierListInfo?.Equals(other.ModifierListInfo) == true)) &&
                   ((Variations == null && other.Variations == null) || (Variations?.Equals(other.Variations) == true)) &&
                   ((ProductType == null && other.ProductType == null) || (ProductType?.Equals(other.ProductType) == true)) &&
                   ((SkipModifierScreen == null && other.SkipModifierScreen == null) || (SkipModifierScreen?.Equals(other.SkipModifierScreen) == true)) &&
                   ((ItemOptions == null && other.ItemOptions == null) || (ItemOptions?.Equals(other.ItemOptions) == true)));
        }
        /// <summary>
        /// Returns true if PatchProductRequestDto instances are equal
        /// </summary>
        /// <param name="other">Instance of PatchProductRequestDto to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PatchProductRequestDto other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ManufacturerId == other.ManufacturerId ||
                     ManufacturerId != null &&
                     ManufacturerId.Equals(other.ManufacturerId)
                     ) &&
                 (
                     CategoryId == other.CategoryId ||
                     CategoryId != null &&
                     CategoryId.Equals(other.CategoryId)
                 ) &&
                 (
                     ProductName == other.ProductName ||
                     ProductName != null &&
                     other.ProductName != null &&
                     ProductName.SequenceEqual(other.ProductName)
                 ));
        }
Exemplo n.º 30
0
 public override bool Equals(Object obj)
 {
     if (obj is Source ob)
     {
         return(Id.Equals(ob.Id) && Name.Equals(ob.Name) && CategoryId.Equals(ob.CategoryId));
     }
     return(false);
 }
Exemplo n.º 31
0
        /// <summary>
        /// Logs to the ULS.
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="traceSeverity">The trace severity.</param>
        /// <param name="message">The message.</param>
        /// <param name="args">The message arguments.</param>
        protected virtual void InnerLog(CategoryId categoryId, TraceSeverity traceSeverity, string message, params object[] args)
        {
            //SPSecurity.RunWithElevatedPrivileges(
            //    () =>
            //    {
            if (_innerLogger == null)
            {
                _innerLogger = new InnerLogger(Name);
            }

            SPDiagnosticsCategory category =
                _innerLogger.Areas[_innerLogger.Name].Categories[categoryId.ToString()];
            _innerLogger.WriteTrace(0, category, traceSeverity, message, args);
            //});
        }