public InfantDetailsResponse GetInfantDetails(string birthId) { InfantDetailsResponse infantDetails = null; try { var query = string.Format(@"select BirthId, FullName, CONVERT(varchar, DOB, 103) AS DOB, POB, MothersName, a.InfantID, b.NextVaccinationDate from InfantDetails a left join vaccinationDetails b on a.infantId = b.InfantId where BirthId ='{0}' AND b.VaccinationId = (SELECT MAX(VaccinationId) FROM vaccinationDetails where InfantID = a.InfantID)", birthId); var infantData = dbService.ExecuteReader(query); if (infantData.Rows.Count > 0) { infantDetails = new InfantDetailsResponse(); infantDetails.BirthId = Convert.ToString(infantData.Rows[0]["BirthId"]); infantDetails.FullName = Convert.ToString(infantData.Rows[0]["FullName"]); infantDetails.DOB = Convert.ToString(infantData.Rows[0]["DOB"]); infantDetails.POB = Convert.ToString(infantData.Rows[0]["POB"]); infantDetails.MothersName = Convert.ToString(infantData.Rows[0]["MothersName"]); infantDetails.InfantId = Convert.ToInt32(infantData.Rows[0]["InfantID"]); infantDetails.NextVaccinationDate = Convert.ToString(infantData.Rows[0]["NextVaccinationDate"]); } } catch { } return(infantDetails); }
public int VerifyLogin(LoginRequest loginRequest) { int userId = 0; string query = string.Format("select UserID from UserDetails where userName='******' and Password = '******'", loginRequest.UserName, loginRequest.Password); var loginData = dbService.ExecuteReader(query); if (loginData.Rows.Count > 0) { userId = Convert.ToInt32(loginData.Rows[0]["UserID"]); } return(userId); }
public AdminFilterCriteriaList GetAdminFilterCriteria() { var vaccinationList = new List <Vaccination>(); var districtList = new List <District>(); var query = "select * from District"; var districtData = dbService.ExecuteReader(query); query = "select SchId, Vaccine from ImmunizationSchedule"; var vaccinationData = dbService.ExecuteReader(query); foreach (DataRow district in districtData.Rows) { var districtItem = new District() { DistrictId = Convert.ToInt32(district["DistrictId"]), DistrictName = Convert.ToString(district["Name"]) }; districtList.Add(districtItem); } foreach (DataRow vaccination in vaccinationData.Rows) { var vaccinationItem = new Vaccination() { VaccinationId = Convert.ToInt32(vaccination["SchId"]), VaccinationName = Convert.ToString(vaccination["Vaccine"]) }; vaccinationList.Add(vaccinationItem); } var adminFilterList = new AdminFilterCriteriaList() { Districts = districtList, Vaccinations = vaccinationList }; return(adminFilterList); }
public IEnumerable <InfantDetailsResponse> SearchInfant(InfantSearchRequest searchRequest) { List <InfantDetailsResponse> infantList = new List <InfantDetailsResponse>(); var query = @"SELECT BirthId, FullName, DOB, POB, MothersName, a.InfantID, b.NextVaccinationDate FROM InfantDetails a LEFT JOIN vaccinationDetails b ON a.infantId = b.InfantId WHERE "; Dictionary <string, string> paramlist = new Dictionary <string, string>(); if (searchRequest.DOB != default(DateTime)) { paramlist.Add("DOB", searchRequest.DOB.ToString()); } if (searchRequest.MothersName != "") { paramlist.Add("MothersName", searchRequest.MothersName); } if (searchRequest.PlaceofBirth != "") { paramlist.Add("POB", searchRequest.PlaceofBirth); } if (searchRequest.BirthId != "") { paramlist.Add("BirthId", searchRequest.BirthId); } int i = 0; foreach (var item in paramlist) { query += item.Key + "='" + item.Value + "'"; i++; if (i != paramlist.Count) { query += " AND "; } } query += " AND b.VaccinationId = (SELECT MAX(VaccinationId) FROM vaccinationDetails where InfantID = a.InfantID)"; var infantDataList = dbService.ExecuteReader(query); foreach (DataRow row in infantDataList.Rows) { var infantData = new InfantDetailsResponse(); infantData.BirthId = Convert.ToString(row["BirthId"]); infantData.FullName = Convert.ToString(row["FullName"]); infantData.DOB = Convert.ToString(row["DOB"]); infantData.POB = Convert.ToString(row["POB"]); infantData.MothersName = Convert.ToString(row["MothersName"]); infantData.InfantId = Convert.ToInt32(row["InfantID"]); infantData.NextVaccinationDate = Convert.ToString(row["NextVaccinationDate"]); infantList.Add(infantData); } return(infantList); }