public int ValidateHomeOrder(Patient patient, string date, int policlinicId) { var repository = new Repository(); var result = repository.IsPatientExists(patient); if (result == -1) { return -1; } return repository.AddHomeVisitHistory(new HomeVisitHistory() { Date = DateTime.Parse(date), Policlinic = repository.GetPoliclinicById(policlinicId), Patient = patient }); }
public int ValidateOrder(Patient patient, int doctorId, string date, string time) { var repository = new Repository(); var result = repository.IsPatientExists(patient); if (result == -1) { return -1; } if (!repository.SetUsedAvailableTimeByTime(DateTime.Parse(date + " " + time), result)) { return -1; } var availableTime = repository.GetAvailableTimeByTime(DateTime.Parse(date + " " + time)); return availableTime != null ? repository.AddOrder(result, doctorId, availableTime.AvailableTimeId) : -1; }
public int ValidateUser(Patient patient) { var repository = new Repository(); return repository.IsPatientExists(patient); }
public int IsPatientExists(Patient patient) { try { var query = "SELECT \"PatientId\" FROM \"PatientTable\" WHERE \"Name\" = @Name AND \"LastName\" = @LastName AND \"Patronymic\" = @Patronymic AND \"BirthDay\" = @BirthDay AND \"Address\" = @Address"; var parameters = new List<NpgsqlParameter>() { new NpgsqlParameter("@Name", patient.FirstName), new NpgsqlParameter("@LastName", patient.LastName), new NpgsqlParameter("@Patronymic", patient.Patronymic), new NpgsqlParameter("@BirthDay", patient.Birthday), new NpgsqlParameter("@Address", patient.Address) }; var results = PostgreSQLHelper_Policlinic.ExecuteParamerizedSelectCommand(query, CommandType.Text, parameters.ToArray()); return results.Rows.Count != 0 ? results.Rows[0].Field<int>("PatientId") : -1; } catch (Exception exception) { return -1; } }