public ExpiredDto IsEvaluationExpired(Int32 programmingID, int evaluationID) { bool active = true; List <EvaluationExpirationListDto> expires = new List <EvaluationExpirationListDto>(); expires = this.evaluationExpirationRepository.GetByprogrammingIDByactive(programmingID, active).Where(e => e.evaluationID == evaluationID).ToList(); bool isExpired = true; string expiredMessage = ""; string expiredAfter = ""; bool isAboutExpired = false; if (expires.Count() == 0) { isExpired = true; expiredMessage = "La carga de notas para esta evaluación aún no está disponible."; expiredAfter = "Cerrado"; } else { int i = expires.Where(e => DateTime.Now.Date <e.startDate || DateTime.Now.Date> e.endDate).Count(); if (i > 0) { EvaluationExpirationListDto evaluationExpired = new EvaluationExpirationListDto(); evaluationExpired = expires.ElementAt(0); if (evaluationExpired != null) { expiredMessage = "La carga de notas para esta evaluación estuvo disponible desde el " + evaluationExpired.startDateShow + " hasta el " + evaluationExpired.endDateShow + "."; expiredAfter = "Cerrado"; } isExpired = true; } else { EvaluationExpirationListDto evaluationExpired = new EvaluationExpirationListDto(); evaluationExpired = expires.ElementAt(0); isExpired = false; expiredMessage = "La carga de notas para esta evaluación se cerrará el " + evaluationExpired.endDateShow + "."; expiredAfter = "Faltan " + TimerAgo.TimeAfter(expires.ElementAt(0).endDate.AddDays(1)); isAboutExpired = ValidAboutExpired(expires.ElementAt(0).endDate.AddDays(1)); } } ExpiredDto expired = new ExpiredDto(); expired.isExpired = isExpired; expired.expiredAfter = expiredAfter; expired.expiredMessage = expiredMessage; expired.isAboutExpired = isAboutExpired; return(expired); }
public List <EvaluationExpirationListDto> GetByprogrammingIDByactive(Int32 programmingID, bool active) { SqlConnection conn = null; SqlDataReader reader; String sql; SqlCommand command; SqlParameter prmprogrammingID = null; SqlParameter prmactive = null; try { EvaluationExpirationListDto evaluationExpiration; List <EvaluationExpirationListDto> lstEvaluationExpirations; conn = new SqlConnection(Functions.GetConnectionString()); sql = "GetEvaluationExpirationByprogrammingIDByactive"; command = new SqlCommand(sql, conn); command.CommandType = CommandType.StoredProcedure; prmprogrammingID = new SqlParameter(); prmprogrammingID.ParameterName = "@programmingID"; prmprogrammingID.SqlDbType = SqlDbType.Int; prmprogrammingID.Value = programmingID; command.Parameters.Add(prmprogrammingID); prmactive = new SqlParameter(); prmactive.ParameterName = "@active"; prmactive.SqlDbType = SqlDbType.Bit; prmactive.Value = active; command.Parameters.Add(prmactive); command.Connection.Open(); reader = command.ExecuteReader(); lstEvaluationExpirations = new List <EvaluationExpirationListDto>(); while (reader.Read()) { evaluationExpiration = new EvaluationExpirationListDto(); evaluationExpiration.startDate = reader.GetDateTime(reader.GetOrdinal("startDate")); evaluationExpiration.endDate = reader.GetDateTime(reader.GetOrdinal("endDate")); evaluationExpiration.evaluationExpirationID = reader.GetInt32(reader.GetOrdinal("evaluationExpirationID")); evaluationExpiration.startDateShow = TimerAgo.TimeShow(evaluationExpiration.startDate, Formater.ShortDateTime()); evaluationExpiration.startDateAgo = TimerAgo.TimeAgo(evaluationExpiration.startDate); evaluationExpiration.endDateShow = TimerAgo.TimeShow(evaluationExpiration.endDate, Formater.ShortDateTime()); evaluationExpiration.endDateAgo = TimerAgo.TimeAgo(evaluationExpiration.endDate); evaluationExpiration.programmingID = reader.GetInt32(reader.GetOrdinal("programmingID")); evaluationExpiration.evaluationID = reader.GetInt32(reader.GetOrdinal("evaluationID")); lstEvaluationExpirations.Add(evaluationExpiration); } command.Connection.Close(); conn.Dispose(); return(lstEvaluationExpirations); } catch (Exception ex) { conn.Dispose(); throw ex; } }