Beispiel #1
0
        public void CheckLoadsForVisibility(List <LoadViewData> loads, string token, List <string> visibilityTypes)
        {
            string topsToGoErrors  = null;
            string project44Errors = null;

            foreach (var load in loads)
            {
                var lte = _loadService.GetLatestTransaction(load.LoadId);

                if (lte.TransactionTypeId != "Accepted")
                {
                    continue;
                }

                if (visibilityTypes.Contains(CarrierVisibilityTypes.TopsToGo))
                {
                    CheckLoadsForTopsToGoVisibilityData(load, lte, token, ref topsToGoErrors);
                }

                if (visibilityTypes.Contains(CarrierVisibilityTypes.Project44))
                {
                    CheckLoadsForProject44VisibilityData(load, lte, token, ref project44Errors);
                }
            }

            //Save all successful updates
            _context.SaveChanges("system");

            //Throw any accumulated errors
            if (!string.IsNullOrWhiteSpace(topsToGoErrors) || !string.IsNullOrWhiteSpace(project44Errors))
            {
                StringBuilder errors = new StringBuilder();

                if (!string.IsNullOrWhiteSpace(topsToGoErrors))
                {
                    errors.Append(topsToGoErrors);
                }

                if (!string.IsNullOrWhiteSpace(project44Errors))
                {
                    if (errors.Length > 0)
                    {
                        errors.AppendLine(project44Errors);
                    }
                    else
                    {
                        errors.Append(project44Errors);
                    }
                }

                throw new Exception(errors.ToString());
            }
        }