public override Dictionary <string, string> HandleValidation(ShipmentMapper shipment) { if (!shipment.Packages.Any() && !_networkProvider.GetShippingBoxes().Any()) { ErrorsResult.Add("Shipment Box Validation error", string.Format(InformationResources.WARN_SHIPMENT_VALIDATION_BOX, shipment.ShipmentNbr.Value)); return(ErrorsResult); } return(Successor != null?Successor.HandleValidation(shipment) : ErrorsResult); }
public override Dictionary <string, string> HandleValidation(ShipmentMapper shipment) { if (shipment.Type.Value != "Shipment") { ErrorsResult.Add("Shipment Type Validation Error", string.Format(InformationResources.WARN_SHIPMENT_VALIDATION_TYPE, shipment.ShipmentNbr.Value)); return(ErrorsResult); } return(Successor != null?Successor.HandleValidation(shipment) : ErrorsResult); }
public override Dictionary <string, string> HandleValidation(ShipmentMapper shipment) { if (shipment.Status.Value != "Open" || shipment.Hold.Value == true) { ErrorsResult.Add("Shipment Status Validation error", string.Format(InformationResources.WARN_SHIPMENT_VALIDATION_OPEN, shipment.ShipmentNbr.Value)); return(ErrorsResult); } return(Successor != null?Successor.HandleValidation(shipment) : ErrorsResult); }
public override Dictionary <string, string> HandleValidation(Models.ApartmentBooking model) { if (model.DateTo == DateTime.MinValue) { ErrorsResult.Add("DateTo", "Date to 2 field is required"); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(model)); } return(ErrorsResult); }
public override Dictionary <string, string> HandleValidation(Models.ApartmentBooking model) { if (model.DateTo <= model.DateFrom) { ErrorsResult.Add("DateTo", "Date to should be grater than Date from"); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(model)); } return(ErrorsResult); }
public override Dictionary <string, string> HandleValidation(ApartmentBooking model) { if (model.DateFrom < new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)) { ErrorsResult.Add("DateFrom", "Date from should be grater than now"); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(model)); } return(ErrorsResult); }
public override List <string> HandleValidation(Animal model) { if (_existingAnimals != null && _existingAnimals.Any(x => x.SpeciesId == model.SpeciesId && x.Name == model.Name)) { ErrorsResult.Add("Multiple animals with the same name and same species not allowed!"); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(model)); } return(ErrorsResult); }
public override List <string> HandleValidation(Animal model) { if (model.YearOfBirth < 1900 || model.YearOfBirth > DateTime.Now.Year) { ErrorsResult.Add($"Year Of Birth must be between 1900 and {DateTime.Now.Year}."); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(model)); } return(ErrorsResult); }
public override List <string> HandleValidation(Animal model) { if (string.IsNullOrWhiteSpace(model.Name)) { ErrorsResult.Add("Name should not be empty."); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(model)); } return(ErrorsResult); }
public override Dictionary <string, string> HandleValidation(ApartmentBooking model) { /* Dummy validation */ if (model.ApartmentType == ApartmentType.OneBedroomExecutive) { ErrorsResult.Add("ApartmentType", string.Format("{0} is currently not avaliable", model.ApartmentType)); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(model)); } return(ErrorsResult); }
public override List <RedirectItemValidationResult> HandleValidation(RedirectItem redirectItem, IEnumerable <RedirectItem> otherRedirectItems) { var response = new RedirectItemValidationResult(); var linkUrl = string.Empty; if (!string.IsNullOrEmpty(redirectItem.LinkUrl)) { linkUrl = redirectItem.LinkUrl; } var destinationRedirect = otherRedirectItems.FirstOrDefault(item => item.Url == linkUrl && item.QueryString == redirectItem.QueryString && item.UniqueId != redirectItem.UniqueId); if (destinationRedirect != null) { if (destinationRedirect.LinkUrl == redirectItem.Url) { response.Status = ImportErrorLevel.Error; response.ErrorMessage = string.Format("This redirect would create a redirect loop as another redirect exists with the URL ({0}) in the file. It has not been imported.", redirectItem.LinkUrl); ErrorsResult.Add(response); return(ErrorsResult); } response.Status = ImportErrorLevel.Warning; response.ErrorMessage = string.Format("This redirect links to the URL ({0}) in the file. This will result in a redirect chain", redirectItem.LinkUrl); ErrorsResult.Add(response); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(redirectItem, otherRedirectItems)); } ErrorsResult.Add(response); return(ErrorsResult); }
/// <summary> /// Handles validation for Source Url /// </summary> /// <param name="redirectItem">A redirect item</param> /// <param name="otherRedirectItems">All redirect items in the file</param> /// <returns></returns> public override List <RedirectItemValidationResult> HandleValidation(RedirectItem redirectItem, IEnumerable <RedirectItem> otherRedirectItems) { var response = new RedirectItemValidationResult(); if (string.IsNullOrEmpty(redirectItem.Url)) { response.Status = ImportErrorLevel.Error; response.ErrorMessage = "No source URL was provided or is in the wrong format"; ErrorsResult.Add(response); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(redirectItem, otherRedirectItems)); } ErrorsResult.Add(response); return(ErrorsResult); }
public override List <RedirectItemValidationResult> HandleValidation(RedirectItem redirectItem, IEnumerable <RedirectItem> otherRedirectItems) { var response = new RedirectItemValidationResult(); var duplicateRedirect = otherRedirectItems.FirstOrDefault(item => item.Url == redirectItem.Url && item.QueryString == redirectItem.QueryString && item.UniqueId != redirectItem.UniqueId); if (duplicateRedirect != null) { response.Status = ImportErrorLevel.Error; response.ErrorMessage = "This redirect has a duplicate row in the file with the same source URL. It has not been imported."; ErrorsResult.Add(response); return(ErrorsResult); } if (Successor != null) { return(Successor.HandleValidation(redirectItem, otherRedirectItems)); } ErrorsResult.Add(response); return(ErrorsResult); }