public static List<LicenseMessage> ValidateThis(this NavOrder order, List<License> licensesInOrder) { var returnMessages = new List<LicenseMessage>(); if (order.IsActionValid() == null) { returnMessages.Add(order.IsActionValid()); return returnMessages; } returnMessages.Add(order.IsProductOrdersEmpty()); returnMessages.Add(order.IsOrderNumberGreaterThan20()); returnMessages.AddRange(order.DoesNumberOfUsersExceed5000()); returnMessages.Add(order.IsOrderNumberNullOrEmpty()); returnMessages.Add(order.IsProductOrdersEmpty()); returnMessages.AddRange(order.AreThereEmptyLicenseKeys()); if (order.Action == (int) ActionEnum.Create) { order.ValidateOrderForNewLicense(licensesInOrder.GetLicenseKeysFromLicenseList()); } else { order.ValidateUpdateOrder(licensesInOrder); } return returnMessages; }
internal static List<LicenseMessage> DoesLicenseKeyExistForUpdate(this NavOrder order, List<License> existingLicenses) { return (from productOrder in order.ProductOrders where !existingLicenses.GetLicenseKeysFromLicenseList().Contains(productOrder.LicenseKey) select new LicenseMessage { Code = ErrorGuids.LicenseKeyDoesntExist , Message = "LicenseKey " + productOrder.LicenseKey + " does not exist" , Severity = (int)MessageStateEnum.Error }).ToList(); }