/// <summary>
        /// Check the failure types and add them to a list.
        /// </summary>
        /// <param name="failureReport">The report contains the types.</param>
        /// <param name="itemsToAdd">Failure types to add.</param>
        /// <returns>A value indicates whether the operation is succeed.</returns>
        private bool CheckTypesAndAdd(FailureReport failureReport, ICollection <FailureItemDto> itemsToAdd)
        {
            if (failureReport == null || itemsToAdd == null)
            {
                throw new ArgumentNullException();
            }

            //get all enabled types
            var failureTypes = _typeRepo.GetAllTypes().ToList();

            if (IsDuplicateOrInvalid(itemsToAdd, failureTypes))
            {
                return(false);
            }

            failureReport.Items = itemsToAdd.Select(item => new FailureItem
            {
                Count  = item.Count,
                Detail = item.Detail,
                Report = failureReport,
                Type   = failureTypes.First(ft => ft.Id == item.TypeId)
            }).ToList();

            return(InSameCategory(failureReport));
        }
Exemple #2
0
 public IQueryable <FailureTypeDto> GetAllTypes()
 {
     return(_faulureTypeRepository.GetAllTypes().ToDto());
 }