示例#1
0
        public int CreateNewHomework(Homework homework, int ID, int courseID)
        {
            int result = 0;

            try
            {
                if (ValidateHomework(homework))
                {
                    result = dal.CreateNewHomework(homework, ID, courseID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
示例#2
0
        public bool ValidateHomework(Homework homework)
        {
            StringBuilder errorList = new StringBuilder();
            bool          validate  = true;

            try
            {
                if (homework.Description == string.Empty)
                {
                    errorList.AppendLine("Description should be provided..");
                    validate = false;
                }
                if (homework.DeadLine.ToString() == string.Empty)
                {
                    errorList.AppendLine("Deadline should be provided");
                    validate = false;
                }
                if (homework.ReqTime.ToString() == string.Empty)
                {
                    errorList.AppendLine("Required time should be provided");
                    validate = false;
                }
                if (homework.LongDescription == string.Empty)
                {
                    errorList.AppendLine("Long description should be provided");
                    validate = false;
                }
                if (validate == false)
                {
                    throw new HomeworkException(errorList.ToString());
                }
            }
            catch (HomeworkException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(validate);
        }
 /// <summary>
 /// 教师发布作业
 /// </summary>
 /// <param name="hw"></param>
 /// <returns></returns>
 public int fabuHw(Homework hw)
 {
     return(new HomeworkService().fabuHw(hw));
 }
示例#4
0
 public void New(Homework homework)
 {
     homeworkDao.New(homework);
 }