public bool Remove(Assignment item, string user) { long assignmentId = Convert.ToInt64(IdOf(item)); string assignmentDeleteText = @"RemoveEmployeeSubscriptions"; IDbConnection connection = DbContext != null && DbContext.Transaction != null ? DbContext.Transaction.Connection : new SqlConnection(DBHelper.ConnectionString); IDbCommand command = DbContext != null && DbContext.Transaction != null ? new SqlCommand(assignmentDeleteText, connection as SqlConnection, DbContext.Transaction as SqlTransaction) : new SqlCommand(assignmentDeleteText) { CommandType = CommandType.StoredProcedure }; return DBHelper.ExecuteNonQuery(connection, command, DbContext == null, new SqlParameter() { ParameterName = "@SubscriptionId", DbType = DbType.Int32, Value = assignmentId }, new SqlParameter() { ParameterName = "@EmployeeId", DbType = DbType.String, Value = item.Emp }, new SqlParameter() { ParameterName = "@ModifiedBy", DbType = DbType.String, Value = user } ) == 1; }
public object IdOf(Assignment item) { return _IdsByHashCode[item.GetHashCode()]; }
private Assignment GetAssignment(IDataReader reader, Status currentStatus) { ReportingArea area = null; //If we have reporting scope, we can assume that we have all of the area columns. if (reader.HasColumn("ReportingScope") && !reader.IsDBNull(reader.GetOrdinal("ReportingScope"))) { area = new ReportingArea( reader.IsDBNull(reader.GetOrdinal("SDst")) ? null : reader.GetString("SDst"), reader.IsDBNull(reader.GetOrdinal("PA")) ? null : reader.GetString("PA"), reader.IsDBNull(reader.GetOrdinal("Abbrev")) ? null : reader.GetString("Abbrev"), reader.IsDBNull(reader.GetOrdinal("RegionID")) ? null : (int?)reader.GetInt32("RegionID"), reader.IsDBNull(reader.GetOrdinal("Region")) ? null : reader.GetString("Region"), (Domain.ReportingScope)(reader.GetInt32("ReportingScope")??1)); } var assignment = new Assignment(); assignment.Name = reader.GetString("SubscriptionDescription") ?? "(missing course name)"; assignment.Assignee = string.Format("{0} {1}", reader.GetString("Firstname"), reader.GetString("Lastname")); assignment.AssignedOn = reader.GetDateTime("AssignedOn") ?? DateTime.Today; assignment.DueDate = reader.GetDateTime("DueDate") ?? DateTime.Today.AddDays(1); assignment.StartDate = reader.GetDateTime("StartDate") ?? DateTime.Today; assignment.CurrentStatus = currentStatus; assignment.Completed = reader.GetBoolean("Completed") ?? false; assignment.CompletedOn = reader.IsDBNull(reader.GetOrdinal("CompletedOn")) ? null : (DateTime?)reader.GetDateTime("CompletedOn"); assignment.Area = area; assignment.TopicDescription = reader.GetString("TopicDescription") ?? "(missing description)"; assignment.Emp = reader.GetString("emp"); assignment.OrderNum = reader.GetInt32("OrderNum") ?? 1; assignment.AssignmentID = reader.GetInt64("AssignmentID") ?? 0; assignment.EmployeeCourseAssignmentID = reader.GetInt64("EmployeeCourseAssignmentID") ?? 0; assignment.CourseTopicAssignmentID = reader.GetInt64("CourseTopicAssignmentID") ?? 0; assignment.CourseTopicID = reader.GetInt32("CourseTopicID") ?? 0; assignment.CourseID = reader.GetInt32("CourseID") ?? 0; assignment.TopicID = reader.GetInt32("TopicID") ?? 0; return assignment; }
public AssignmentPresentation(Assignment assignment, IList<PresentationStep> steps) { Assignment = assignment; Steps = steps; }