public string Validate(Order model) { try { _logger.LogInformation("Start order validating."); StringBuilder builder = new StringBuilder(); if (!ValidationUtilities.NotEmptyRule(model.Addres)) { builder.AppendLine("Your address should not be empty."); } if (!ValidationUtilities.NotEmptyRule(model.FullName)) { builder.AppendLine("Your full name should not be empty."); } if (!ValidationUtilities.OnlyLettersNumbersAndUnderscorcesRule(model.FullName)) { builder.AppendLine("Your full name should contains only letters, dots, commas and number."); } if (!ValidationUtilities.NotNullRule(model.DeliveryId)) { builder.AppendLine("You must choose a delivery service."); } string message = builder.ToString(); if (!string.IsNullOrEmpty(message)) { return(message); } _logger.LogInformation("Order successfuly validated."); return(null); } catch (Exception exception) { _logger.LogError(exception.Message); throw exception; } }