示例#1
0
        public UncertainItemDTO(UncertainItem uncertainItem)
        {
            this.ID = uncertainItem.ID;
            this.AgencyID = uncertainItem.AgencyID;
            this.ChapterID = uncertainItem.ChapterID;
            this.IsVipItem = uncertainItem.IsVipItem;

            this.Title = uncertainItem.Title;
            this.Image = uncertainItem.Image;
            this.Difficulty = uncertainItem.Difficulty;
            this.AddPerson = uncertainItem.AddPerson;
            this.AddTime = uncertainItem.AddTime;
        }
示例#2
0
        /// <summary>
        /// 添加不定项选择题
        /// </summary>
        public ServiceInvokeDTO AddUncertain(UncertainItem uncertain)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;
            try
            {
                uncertainDAL.Insert(uncertain);
                result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
示例#3
0
        /// <summary>
        /// 更新不定项选择题
        /// </summary>
        public ServiceInvokeDTO UpdateUncertain(UncertainItem uncertain)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;
            try
            {
                UncertainItem dbUncertain = uncertainDAL.GetByID(uncertain.ID);
                if (dbUncertain != null)
                {
                    uncertainDAL.Update(uncertain);
                    result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
                }
                else
                {
                    result = new ServiceInvokeDTO(InvokeCode.SYS_OBJECT_NOT_EXIST_ERROR);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
示例#4
0
        public ActionResult AddUncertain()
        {
            log.Debug(Constant.DEBUG_START);

            string isVipItemString = ApiQueryUtil.QueryArgByPost("is_vip_item");
            string chapterIDString = ApiQueryUtil.QueryArgByPost("chapter_id");

            string title = ApiQueryUtil.QueryArgByPost("title");
            HttpPostedFileBase imageFile = Request.Files["image"];
            string difficultyString = ApiQueryUtil.QueryArgByPost("difficulty");

            ServiceInvokeDTO result = null;
            try
            {
                UncertainItem uncertain = new UncertainItem();
                uncertain.AgencyID = (Session[Constant.SESSION_KEY_ADMIN] as AgencyAdminDTO).Agency.ID;
                uncertain.IsVipItem = Convert.ToInt32(isVipItemString);
                uncertain.ChapterID = Convert.ToInt32(chapterIDString);

                uncertain.Title = title;
                uncertain.Difficulty = Convert.ToInt32(difficultyString);
                uncertain.AddPerson = (Session[Constant.SESSION_KEY_ADMIN] as AgencyAdminDTO).ChineseName;

                if (imageFile != null)
                {
                    byte[] imageBytes = null;
                    using (Stream inputStream = imageFile.InputStream)
                    {
                        MemoryStream memoryStream = inputStream as MemoryStream;
                        if (memoryStream == null)
                        {
                            memoryStream = new MemoryStream();
                            inputStream.CopyTo(memoryStream);
                        }
                        imageBytes = memoryStream.ToArray();
                    }
                    uncertain.Image = imageBytes;
                }

                result = itemDataService.AddUncertain(uncertain);
            }
            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);
        }
示例#5
0
        /// <summary>
        /// 添加实体信息,返回添加成功后的主键ID
        /// </summary>
        public int Insert(UncertainItem uncertain)
        {
            int id = 0;

            const string sql = @"INSERT INTO UncertainItem(AgencyID, ChapterID, IsVipItem, Title, Image, Difficulty, AddPerson)
                               VALUES (@AgencyID, @ChapterID, @IsVipItem, @Title, @Image, @Difficulty, @AddPerson);
                               SELECT LAST_INSERT_ID();";
            using (DbConnection connection = ConnectionManager.OpenConnection)
            {
                id = connection.Query<int>(sql, uncertain).SingleOrDefault<int>();
            }
            return id;
        }
示例#6
0
 /// <summary>
 /// 更新实体信息
 /// </summary>
 public void Update(UncertainItem uncertain)
 {
     const string sql = @"UPDATE UncertainItem SET ChapterID = @ChapterID, IsVipItem= @IsVipItem,
                          Title= @Title, Image = @Image, Difficulty = @Difficulty WHERE IsDeleted = 0 AND ID = @ID";
     using (DbConnection connection = ConnectionManager.OpenConnection)
     {
         connection.Execute(sql, uncertain);
     }
 }