/// <summary>
        /// Returns current fee of a field with value
        /// </summary>
        public static int GetCurrentFee(this FieldWithValue self)
        {
            if (!self.Field.FieldType.SupportsPricing())
            {
                return(0);
            }
            return(self.Field.FieldType
                   switch
            {
                ProjectFieldType.Checkbox => self.HasEditableValue ? self.Field.Price : 0,
                ProjectFieldType.Number => self.ToInt() * self.Field.Price,
                ProjectFieldType.Dropdown => self.GetDropdownValues().Sum(v => v.Price),
                ProjectFieldType.MultiSelect => self.GetDropdownValues().Sum(v => v.Price),

                _ => throw new NotSupportedException("Can't calculate pricing"),
            });
Exemplo n.º 2
0
        /// <summary>
        /// Returns current fee of a field with value
        /// </summary>
        public static int GetCurrentFee(this FieldWithValue self)
        {
            switch (self.Field.FieldType)
            {
            case ProjectFieldType.Checkbox:
                return(self.HasEditableValue ? self.Field.Price : 0);

            case ProjectFieldType.Number:
                return(self.ToInt() * self.Field.Price);

            case ProjectFieldType.Dropdown:
            case ProjectFieldType.MultiSelect:
                return(self.GetDropdownValues().Sum(v => v.Price));

            default:
                return(0);
            }
        }
Exemplo n.º 3
0
        public static void MarkUsed([NotNull] this FieldWithValue field)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            if (!field.Field.WasEverUsed)
            {
                field.Field.WasEverUsed = true;
            }

            if (field.Field.HasValueList())
            {
                foreach (var val in field.GetDropdownValues().Where(v => !v.WasEverUsed))
                {
                    val.WasEverUsed = true;
                }
            }
        }