Esempio n. 1
0
        private ICollection <AdditionalFieldValue> CreateFields(AdditionalField field, Guid RequestId, string Value)
        {
            var selectedValue = new SelectedValues();

            selectedValue.Value = Value;

            var values = new List <SelectedValues>()
            {
                selectedValue
            };

            var fieldValue = new AdditionalFieldValue
            {
                Id = Guid.NewGuid(),
                AdditionalFieldId = field.Id,
                Values            = values,
                RequestId         = RequestId
            };

            List <AdditionalFieldValue> fields = new List <AdditionalFieldValue>()
            {
                fieldValue
            };

            return(fields);
        }
Esempio n. 2
0
        public void RequestsControllerUpdateTest()
        {
            var type            = CreateContext();
            var additionalField = CreateFieldLogicWithRanges(type);
            var RequestId       = Guid.NewGuid();
            var Logic           = CreateLogic();
            var Controller      = new RequestsController(Logic);

            AdditionalFieldValue fieldRangeValue = new AdditionalFieldValue()
            {
                Id = Guid.NewGuid(),
                AdditionalFieldId = additionalField.Id,
                RequestId         = RequestId
            };

            var selectedValue = new SelectedValues();

            selectedValue.Value = "01/15/1993";

            var values = new List <SelectedValues>()
            {
                selectedValue
            };

            fieldRangeValue.Values = values;

            var valuesList = new List <AdditionalFieldValue>()
            {
                fieldRangeValue
            };

            Request Request = new Request()
            {
                Id                    = RequestId,
                RequestorsName        = "Just Testing",
                RequestorsEmail       = "*****@*****.**",
                RequestorsPhone       = "489498948894",
                TypeId                = type.Id,
                AdditionalFieldValues = valuesList
            };

            Logic.Create(Request);

            Request.State = "En Revision";

            var result        = Controller.Put(RequestId, RequestDTO.ToModel(Request));
            var createdResult = result as CreatedAtRouteResult;
            var model         = createdResult.Value as RequestDTO;

            Assert.AreEqual("En Revision", model.State);
        }
Esempio n. 3
0
        public void IsValidRangeValue(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
        {
            if (additionalFieldValue.Values.Count > 1)
            {
                throw new ExceptionController(LogicExceptions.INVALID_MULTISELECTION);
            }

            Boolean boolValue;

            if (!Boolean.TryParse(additionalFieldValue.Values.ToList().First().Value, out boolValue))
            {
                throw new ExceptionController(LogicExceptions.INVALID_BOOLEAN);
            }
        }
Esempio n. 4
0
        public void IsValidRangeValue(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
        {
            if (additionalFieldValue.Values.Count > 1)
            {
                throw new ExceptionController(LogicExceptions.INVALID_MULTISELECTION);
            }

            /* Validate Value Within Ranges */
            DateTime incomingDate = ConvertStringToDate(additionalFieldValue.Values.ToList().First().Value);
            var      FromToDates  = ConvertRangesToDates(additionalField);

            if (!(incomingDate >= FromToDates[0] && incomingDate <= FromToDates[1]))
            {
                throw new ExceptionController(LogicExceptions.DATE_OUT_OF_RANGE);
            }
        }
Esempio n. 5
0
        public void IsValidRangeValue(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
        {
            if (additionalFieldValue.Values.Count > 1)
            {
                throw new ExceptionController(LogicExceptions.INVALID_MULTISELECTION);
            }

            if (additionalField.Ranges.Count > 0)
            {
                FieldRange field = new FieldRange();
                field.Range = additionalFieldValue.Values.ToList().First().Value;

                if (!additionalField.Ranges.Contains(field))
                {
                    throw new ExceptionController(LogicExceptions.INVALID_ADDITIONAL_FIELD_RANGES);
                }
            }
        }
Esempio n. 6
0
        public void IsValidRangeValue(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
        {
            if (additionalFieldValue.Values.Count > 1)
            {
                throw new ExceptionController(LogicExceptions.INVALID_MULTISELECTION);
            }

            /* Validate Value Within Ranges */
            var incomingNumber = ConvertStringToInt(additionalFieldValue.Values.ToList().First().Value);

            if (additionalField.Ranges.Count > 0)
            {
                var FromToNumbers = ConvertRangesToInts(additionalField);

                if (!(incomingNumber >= FromToNumbers[0] && incomingNumber <= FromToNumbers[1]))
                {
                    throw new ExceptionController(LogicExceptions.NUMBER_OUT_OF_RANGE + " for the following additional field: " + additionalField.Id);
                }
            }
        }
Esempio n. 7
0
        public void HasValidRangeValues(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
        {
            if (additionalField.Ranges.Count > 0 && additionalFieldValue.Values.Count > 0)
            {
                foreach (SelectedValues selection in additionalFieldValue.Values)
                {
                    FieldRange field = new FieldRange();
                    field.Range = selection.Value;

                    if (!additionalField.Ranges.Contains(field))
                    {
                        throw new ExceptionController(LogicExceptions.INVALID_ADDITIONAL_FIELD_RANGES);
                    }
                }
            }
            else
            {
                throw new ExceptionController(LogicExceptions.INVALID_SELECTION);
            }
        }
Esempio n. 8
0
        public void HasValidRangeValues(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
        {
            if (additionalField.Ranges.Count > 0 && additionalFieldValue.Values.Count > 0)
            {
                foreach (SelectedValues selection in additionalFieldValue.Values)
                {
                    /* Validate Value Within Ranges */
                    DateTime incomingDate = ConvertStringToDate(selection.Value);
                    var      FromToDates  = ConvertRangesToDates(additionalField);

                    if (!(incomingDate >= FromToDates[0] && incomingDate <= FromToDates[1]))
                    {
                        throw new ExceptionController(LogicExceptions.DATE_OUT_OF_RANGE);
                    }
                }
            }
            else
            {
                throw new ExceptionController(LogicExceptions.INVALID_SELECTION);
            }
        }
Esempio n. 9
0
        public void HasValidRangeValues(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
        {
            if (additionalField.Ranges.Count > 0 && additionalFieldValue.Values.Count > 0)
            {
                foreach (SelectedValues selection in additionalFieldValue.Values)
                {
                    /* Validate Value Within Ranges */
                    var incomingNumber = ConvertStringToInt(selection.Value);
                    var FromToNumbers  = ConvertRangesToInts(additionalField);

                    if (!(incomingNumber >= FromToNumbers[0] && incomingNumber <= FromToNumbers[1]))
                    {
                        throw new ExceptionController(LogicExceptions.NUMBER_OUT_OF_RANGE + " for the following additional field: " + additionalField.Id);
                    }
                }
            }
            else
            {
                throw new ExceptionController(LogicExceptions.INVALID_SELECTION);
            }
        }
Esempio n. 10
0
 public void HasValidRangeValues(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
 {
     IsValidRangeValue(additionalField, additionalFieldValue);
 }
Esempio n. 11
0
 public void HasValidRangeValues(AdditionalField additionalField, AdditionalFieldValue additionalFieldValue)
 {
     this._validationStrategy.HasValidRangeValues(additionalField, additionalFieldValue);
 }