예제 #1
0
        public ActionResult UpdateCourse()
        {
            log.Debug(Constant.DEBUG_START);

            string idString = ApiQueryUtil.QueryArgByPost("id");
            string name = ApiQueryUtil.QueryArgByPost("name");
            string description = ApiQueryUtil.QueryArgByPost("description");

            ServiceInvokeDTO result = null;
            try
            {
                Course course = new Course();
                course.ID = Convert.ToInt32(idString);
                course.Name = name;
                course.Description = description;

                result = itemDataService.UpdateCourse(course);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                result = new ServiceInvokeDTO(InvokeCode.SYS_INNER_ERROR);
            }

            string json = JsonConvert.SerializeObject(result, Formatting.Indented, Constant.TIME_CONVERTER);
            log.Debug(Constant.DEBUG_END);

            return Content(json, Constant.JSON_MIME_TYPE);
        }
예제 #2
0
파일: CourseDAL.cs 프로젝트: yienit/SLOES
        /// <summary>
        /// 添加实体信息,返回添加成功后的主键ID
        /// </summary>
        public int Insert(Course course)
        {
            int id = 0;

            const string sql = @"INSERT INTO Course(Name, Description) VALUES (@Name, @Description);
                               SELECT LAST_INSERT_ID();";
            using (DbConnection connection = ConnectionManager.OpenConnection)
            {
                id = connection.Query<int>(sql, course).SingleOrDefault<int>();
            }
            return id;
        }
예제 #3
0
파일: CourseDAL.cs 프로젝트: yienit/SLOES
 /// <summary>
 /// 更新实体信息
 /// </summary>
 public void Update(Course course)
 {
     const string sql = @"UPDATE Course SET Name = @Name, Description= @Description WHERE IsDeleted = 0 AND ID = @ID";
     using (DbConnection connection = ConnectionManager.OpenConnection)
     {
         connection.Execute(sql, course);
     }
 }
예제 #4
0
        /// <summary>
        /// 添加科目信息
        /// </summary>
        public ServiceInvokeDTO AddCourse(Course course)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;
            try
            {
                // check name
                Course dbCourse = courseDAL.GetByName(course.Name);
                if (dbCourse == null)
                {
                    courseDAL.Insert(course);
                    result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
                }
                else
                {
                    result = new ServiceInvokeDTO(InvokeCode.ITEM_COURSE_NAME_EXIST_ERROR);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }