Beispiel #1
0
        public int UpdateCriterion(CriterionObject criterion)
        {
            try
            {
                string insQuery = "UPDATE [dbo].[criteria_tbl] SET [criteriaName] = @CriteriaName,[Description] = @Description, [rubricId] = @RubricId WHERE  [criteriaId] = @CriteriaId";

                SqlParameter param1, param2, param3, param4;

                param1       = new SqlParameter("@CriteriaName", SqlDbType.NVarChar, 50, "criteriaName");
                param1.Value = criterion.CriteriaName;

                param2       = new SqlParameter("@Description", SqlDbType.NVarChar, 200, "Description");
                param2.Value = criterion.Description;

                param3       = new SqlParameter("@RubricId", SqlDbType.Int, int.MaxValue, "rubricId");
                param3.Value = criterion.Rubric.RubricId;

                param4       = new SqlParameter("@CriteriaId", SqlDbType.Int, int.MaxValue, "criteriaId");
                param3.Value = criterion.CriteriaId;

                if (criterion == null)
                {
                    throw new NullReferenceException();
                }
                else
                {
                    sqlParameters = new List <SqlParameter>();
                    sqlParameters.Add(param1);
                    sqlParameters.Add(param2);
                    sqlParameters.Add(param3);
                    sqlParameters.Add(param4);

                    instructorDataAccess = new DataAccess();

                    Task <int> task = Task.Run(() => instructorDataAccess.ExecuteCommandAsync(insQuery, CommandType.Text, sqlParameters));

                    return(task.Result);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #2
0
        public CriterionObject ViewCriterion(int criterionId)
        {
            try
            {
                string sqlSelect = $"SELECT [criteriaId],[criteriaName],[Description], cr. [rubricId], r.rubricName FROM [criteria_tbl] cr JOIN rubric_tbl r ON r.rubricId = cr.rubricId where criteriaId = @CriteriaId";

                instructorDataAccess = new DataAccess();
                CriterionObject criterionObject = new CriterionObject();
                parameters = new List <ParameterList>();

                parameters.Add(new ParameterList()
                {
                    Key = "@CriteriaId", Value = criterionId
                });

                Task <DataTable> task = Task.Run(() => instructorDataAccess.GetDataAsync(sqlSelect, parameters));

                criterionObject.CriteriaId        = Convert.ToInt32(task.Result.Columns["criteriaId"]);
                criterionObject.CriteriaName      = task.Result.Columns["criteriaName"].ToString();
                criterionObject.Rubric.RubricId   = Convert.ToInt32(task.Result.Columns["rubricId"]);
                criterionObject.Rubric.RubricName = task.Result.Columns["rubricName"].ToString();
                criterionObject.Description       = task.Result.Columns["criteriaId"].ToString();

                if (criterionObject == null)
                {
                    throw new NullReferenceException();
                }
                else
                {
                    return(criterionObject);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }