private bool ValidationAddressFields(Address address, bool isCreation) { TreatmentAddressFields(address); // Variaveis utilizadas para validação IDictionary <string, string> stringFields = new Dictionary <string, string>(); IDictionary <string, string> stringFieldsOnlyNumbers = new Dictionary <string, string>(); stringFields.Add("PublicPlace", address.PublicPlace); stringFields.Add("Neighborhood", address.Neighborhood); stringFields.Add("City", address.City); stringFieldsOnlyNumbers.Add("Number", address.Number); stringFieldsOnlyNumbers.Add("ZipCode", address.ZipCode); if (!UseFul.ValidStringFill(stringFields, ref replyMessage, ref httpStatus)) { return(false); } if (!ValidadeAddressStringLength(address)) { return(false); } if (!UseFul.ValidStringFillOnlyNumbers(stringFieldsOnlyNumbers, ref replyMessage, ref httpStatus)) { return(false); } if (new ClientDao().Read(address.IdClient) == null) { httpStatus = HttpStatusCode.InternalServerError; replyMessage = "O endereço não está associação a um cliente válido"; return(false); } if (CustomerAddressExists(address.ZipCode, address.Number, address.IdClient, address.IdAddress, isCreation)) { return(false); } return(true); }
private bool ValidationClientFields(Client client) { TreatmentClientFields(client); // Variaveis utilizadas para validação IDictionary <string, string> stringFields = new Dictionary <string, string>(); IDictionary <string, string> stringFieldsOnlyNumbers = new Dictionary <string, string>(); stringFields.Add("Name", client.Name); stringFields.Add("LastName", client.LastName); stringFields.Add("Email", client.Email); stringFieldsOnlyNumbers.Add("Cpf", client.Cpf); stringFieldsOnlyNumbers.Add("DDD", client.DDD); stringFieldsOnlyNumbers.Add("Telephone", client.Telephone); if (!UseFul.ValidStringFill(stringFields, ref replyMessage, ref httpStatus)) { return(false); } if (!ValidadeClientStringLength(client)) { return(false); } if (!UseFul.ValidStringFillOnlyNumbers(stringFieldsOnlyNumbers, ref replyMessage, ref httpStatus)) { return(false); } if (!UseFul.DateIsValid(client.BirthDate, "BirthDate", ref replyMessage, ref httpStatus)) { return(false); } if (!VerifyExistenceCpf(client.Cpf, client.IdClient)) { return(false); } return(true); }