private void DoDateAndTimeValidation(AppointmentViewModel viewModel, DateTime localNow, int? excludeAppointmentId)
        {
            if (viewModel.LocalDateTime != viewModel.LocalDateTime.Date)
                throw new ArgumentException("viewModel.Date must be the date alone, without time data.");

            var inconsistencyMessages = new ModelStateDictionary();
            if (!string.IsNullOrEmpty(viewModel.Start) && !string.IsNullOrEmpty(viewModel.End))
            {
                var startTimeLocal = viewModel.LocalDateTime + DateTimeHelper.GetTimeSpan(viewModel.Start);
                var endTimeLocal = viewModel.LocalDateTime + DateTimeHelper.GetTimeSpan(viewModel.End);

                var startTimeUtc = ConvertToUtcDateTime(this.DbPractice, startTimeLocal);
                var endTimeUtc = ConvertToUtcDateTime(this.DbPractice, endTimeLocal);

                var isTimeAvailable = IsTimeAvailableUtc(startTimeUtc, endTimeUtc, this.Doctor.Appointments, excludeAppointmentId);
                if (!isTimeAvailable)
                {
                    inconsistencyMessages.AddModelError(
                        () => viewModel.LocalDateTime,
                        "A data e hora já está marcada para outro compromisso.");
                }
            }

            // Setting the error message to display near the date and time configurations.
            var emptyErrors = new ModelErrorCollection();
            var errorsList = new List<ModelError>();
            errorsList.AddRange(this.ModelState.GetPropertyErrors(() => viewModel.LocalDateTime) ?? emptyErrors);
            errorsList.AddRange(this.ModelState.GetPropertyErrors(() => viewModel.Start) ?? emptyErrors);
            errorsList.AddRange(this.ModelState.GetPropertyErrors(() => viewModel.End) ?? emptyErrors);

            // Flag that tells whether the time and date are valid ot not.
            viewModel.DateAndTimeValidationState =
                errorsList.Any() ? DateAndTimeValidationState.Failed :
                !inconsistencyMessages.IsValid ? DateAndTimeValidationState.Warning :
                DateAndTimeValidationState.Passed;

            // Continue filling error list with warnings.
            errorsList.AddRange(inconsistencyMessages.GetPropertyErrors(() => viewModel.LocalDateTime) ?? emptyErrors);
            errorsList.AddRange(inconsistencyMessages.GetPropertyErrors(() => viewModel.Start) ?? emptyErrors);
            errorsList.AddRange(inconsistencyMessages.GetPropertyErrors(() => viewModel.End) ?? emptyErrors);
            if (errorsList.Any())
            {
                viewModel.TimeValidationMessage = errorsList.First().ErrorMessage;
            }
        }