protected void SubmitPatientVideo(object sender, EventArgs e) { try { var patientVideo = new PatientEducationModel(); patientVideo.Name = video_name.Value; patientVideo.Url = video_url.Value; patientVideo.Speciality = int.Parse(speciality.Value); patientVideo.IsActive = true; patientVideo.Created = DateTime.UtcNow.AddHours(5).AddMinutes(30); var sqlQuery = new Helper().GetInsertQuery <PatientEducationModel>(patientVideo); if (!string.IsNullOrWhiteSpace(video_id.Value)) { patientVideo.Id = int.Parse(video_id.Value); sqlQuery = new Helper().GetUpdateQuery <PatientEducationModel>(patientVideo); } var dam = new DataAccessManager().ExecuteInsertUpdateQuery(sqlQuery); if (dam) { Response.Redirect("PatientEducation", true); } } catch (Exception ex) { action.Value = "Failed To Add Video!"; } }
public PagedList <PatientEducationModel> GetAllPatientEducationsPaginated(int skip, int take, string order, string where) { var patientEdus = new List <PatientEducationModel>(); var orderBy = string.IsNullOrEmpty(order) ? " order by pe.created_on desc " : order; var query = "select pe.*, sm.speciality_name from " + TABLE_NAME + " pe, speciality_master sm where pe.speciality_id = sm.speciality_id and pe.is_active='y' " + where + orderBy + " limit " + take + " offset " + skip; var rows = new DataAccessManager().ExecuteSelectQuery(query); if (rows != null && rows.Count > 0) { foreach (DataRow r in rows) { var patientEdu = new PatientEducationModel(); var props = typeof(PatientEducationModel).GetProperties(); foreach (var prop in props) { var ignore = Attribute.IsDefined(prop, typeof(IgnoreSelect)); if (!ignore) { var attribute = prop.GetCustomAttributes(typeof(DisplayNameAttribute), true).Cast <DisplayNameAttribute>().Single(); string displayName = attribute.DisplayName; var value = r[displayName]; var pType = prop.PropertyType; object v = null; if (pType == typeof(bool)) { v = value.ToString() == "y"; } else { v = value == null ? null : value; } var variable = prop.SetMethod; if (!r.IsNull(displayName)) { variable.Invoke(patientEdu, new object[] { v }); } } } patientEdus.Add(patientEdu); } } query = "select count(*) from " + TABLE_NAME + " pe, speciality_master sm where sm.speciality_id = pe.speciality_id and pe.is_active='y' " + where; var totalCount = new DataAccessManager().ExecuteScalar(query); var count = totalCount != null?int.Parse(totalCount.ToString()) : 0; var result = new PagedList <PatientEducationModel>() { TotalCount = count, Data = patientEdus }; return(result); }
public List <PatientEducationModel> GetAllPatientEducations() { var patientEdus = new List <PatientEducationModel>(); var query = "select * from " + TABLE_NAME + " where is_active='y' order by created_on desc"; var rows = new DataAccessManager().ExecuteSelectQuery(query); if (rows != null && rows.Count > 0) { foreach (DataRow r in rows) { var patientEdu = new PatientEducationModel(); var props = typeof(PatientEducationModel).GetProperties(); foreach (var prop in props) { var ignore = Attribute.IsDefined(prop, typeof(IgnoreInsert)); if (!ignore) { var attribute = prop.GetCustomAttributes(typeof(DisplayNameAttribute), true).Cast <DisplayNameAttribute>().Single(); string displayName = attribute.DisplayName; var value = r[displayName]; var pType = prop.PropertyType; object v = null; if (pType == typeof(bool)) { v = value.ToString() == "y"; } else { v = value == null ? null : value; } var variable = prop.SetMethod; if (!r.IsNull(displayName)) { variable.Invoke(patientEdu, new object[] { v }); } } } patientEdus.Add(patientEdu); } } return(patientEdus); }