Beispiel #1
0
 public ActionResult PutVerify([FromBody] Model.WorkInfo workInfo)  //修改活动审核情况
 {
     try
     {
         var n = DAL.WorkInfo.Instance.UpdateVerify(workInfo);
         if (n != 0)
         {
             return(Json(Result.Ok("审核活动成功", workInfo.workId)));
         }
         else
         {
             return(Json(Result.Err("workId不存在")));
         }
     }
     catch (Exception ex)
     {
         if (ex.Message.ToLower().Contains("null"))
         {
             return(Json(Result.Err("作品审核情况不能为空")));
         }
         else
         {
             return(Json(Result.Err(ex.Message)));
         }
     }
 }
Beispiel #2
0
 public ActionResult Put([FromBody] Model.WorkInfo workInfo)  //发布活动(添加新活动),并将src的网站路径删除,防止服务器地址变化时,客户端无法访问
 {
     workInfo.recommend  = "否";
     workInfo.workVerify = "待审核";
     workInfo.uploadTime = DateTime.Now;
     try
     {
         var n = DAL.WorkInfo.Instance.Update(workInfo);
         if (n != 0)
         {
             return(Json(Result.Ok("修改作品成功", workInfo.workId)));
         }
         else
         {
             return(Json(Result.Err("workId不存在")));
         }
     }
     catch (Exception ex)
     {
         if (ex.Message.ToLower().Contains("foreign key"))
         {
             return(Json(Result.Err("作品名称、作品图片、作品审核情况、用户名、是否推荐不能为空")));
         }
         else
         {
             return(Json(Result.Err(ex.Message)));
         }
     }
 }
Beispiel #3
0
 public ActionResult upImg(string id, List<IFormFile> files)
 {
     var path = System.IO.Path.Combine(_hostingEnvironment.WebRootPath, "img", "Work");
     var fileName = $"{path}/{id}";
     try
     {
         var ext = DAL.Upload.Instance.UpImg(files[0], fileName);
         if (ext == null)
             return Json(Result.Err("请上传图片文件"));
         else
         {
             var file = $"img/Work/{id}{ext}";
             Model.WorkInfo workInfo = new Model.WorkInfo();
             if (id.StartsWith("i"))
             {
                 workInfo.workId = int.Parse(id.Substring(1));
                 workInfo.workIntroduction = file;
             }
             else
             {
                 workInfo.workId = int.Parse(id);
                 workInfo.workIntroduction = file;
             }
             var n = DAL.WorkInfo.Instance.UpdateImg(workInfo);
             if (n > 0)
                 return Json(Result.Ok("上传成功"));
             else
                 return Json(Result.Err("请输入正确的作品id"))l
         }
     }
     catch(Exception ex)
     {
         return Json(Result.Err(ex.Message));
     }
 }
Beispiel #4
0
 public ActionResult Post([FromBody] Model.WorkInfo workInfo)
 {
     workInfo.recommend  = "否";
     workInfo.workVerify = "待审核";
     workInfo.uploadTime = DateTime.Now;
     try
     {
         int n = DAL.WorkInfo.Instance.Add(workInfo);
         return(Json(Result.Ok("发布作品成功", n)));
     }
     catch (Exception ex)
     {
         if (ex.Message.ToLower().Contains("foreign key"))
         {
             if (ex.Message.ToLower().Contains("username"))
             {
                 return(Json(Result.Err("合法用户才能添加记录")));
             }
             else
             {
                 return(Json(Result.Err("作品所属活动不存在")));
             }
         }
         else if (ex.Message.ToLower().Contains("null"))
         {
             return(Json(Result.Err("作品名称、作品图片、上传作品时间、作品审核情况、用户名、是否推荐不能为空")));
         }
         else
         {
             return(Json(Result.Err(ex.Message)));
         }
     }
 }
Beispiel #5
0
 public ActionResult Put([FromBody] Model.WorkInfo workInfo)
 {
     workInfo.recommend  = "否";
     workInfo.workVerify = "待审核";
     workInfo.uploadTime = DateTime.Now;
     try
     {
         var n = DAL.WorkInfo.Instance.Update(workInfo);
         if (n != 0)
         {
             return(Json(Result.Ok("修改作品成功", workInfo.workId)));
         }
         else
         {
             return(Json(Result.Err("workId不存在")));
         }
     }
     catch (Exception ex)
     {
         if (ex.Message.ToLower().Contains("null"))
         {
             return(Json(Result.Err("作品名称、作品图片、上传作品时间、作品审核、用户名、是否推荐不能为空")));
         }
         else
         {
             return(Json(Result.Err(ex.Message)));
         }
     }
 }
Beispiel #6
0
        public ActionResult PutRecommend([FromBody] Model.WorkInfo workInfo)   //修改活动推荐情况
        {
            workInfo.recommendTime = DateTime.Now;
            try
            {
                var re = "";
                if (workInfo.recommend == "否")
                {
                    re = "取消";
                }
                var n = DAL.WorkInfo.Instance.UpdateRecommend(workInfo);

                if (n != 0)
                {
                    return(Json(Result.Ok($"{re}推荐作品成功", workInfo.workId)));
                }
                else
                {
                    return(Json(Result.Err("workId不存在")));
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower().Contains("null"))
                {
                    return(Json(Result.Err("推荐作品情况不能为空")));
                }
                else
                {
                    return(Json(Result.Err(ex.Message)));
                }
            }
        }
Beispiel #7
0
 public int UpdateRecommend(Model.WorkInfo workInfo)
 {
     using (IDbConnection cn = new MySqlConnection(cns))
     {
         string sql = "update workinfo set recommend=@recommend,recommendTime=@recommendTime where workId=@workId";
         return(cn.Execute(sql, workInfo));
     }
 }
Beispiel #8
0
 public int UpdateVerify(Model.WorkInfo workInfo)
 {
     using (IDbConnection cn = new MySqlConnection(cns))
     {
         string sql = "update workinfo set workVerify=@workVerify where workId=@workId";
         return(cn.Execute(sql, workInfo));
     }
 }
Beispiel #9
0
 public int Update(Model.WorkInfo workInfo)
 {
     using (IDbConnection cn = new MySqlConnection(cns))
     {
         string sql = "update workinfo set workName=@workName,workPicture=@workPicture,uploadTime,workIntroduction=@workIntroduction,workVerify=@workVerify," + "userName=@userName,recommend=@recommend,recommendTime=@recommendTime where workId=@workId";
         return(cn.Execute(sql, workInfo));
     }
 }
Beispiel #10
0
 public int Update(Model.WorkInfo workinfo)
 {
     using (IDbConnection cn = new MySqlConnection(cns))
     {
         string sql = "update workinfo set workName=@workName,workPicture=@workPicture";
         return(cn.Execute(sql, workinfo));
     }
 }
Beispiel #11
0
 public int Add(Model.WorkInfo workInfo)
 {
     using (IDbConnection cn = new MySqlConnection(cns))
     {
         string sql = "insert into workinfo(workId,workName,workPicture,uploadTime,workIntroduction,workVerify,userName,activityId,recommend,recommendTime)" + "values(@workId,@workName,@workPicture,@uploadTime,@workIntroduction,@workVerify,@userName,@activityId,@recommend,@recommendTime);";
         sql += "SELECT @@TDENTITY";
         return(cn.ExecuteScalar <int>(sql, workInfo));
     }
 }
Beispiel #12
0
 public int UpdateImg(Model.WorkInfo workInfo)
 {
     using (IDbConnection cn = new MySqlConnection(cns))
     {
         string sql = "update workinfo set workPicture=@workPicture where workId=@workId";
         if (workInfo.workPicture == null)
         {
             sql = "update workinfo set workIntroduction=@workIntroduction where workId=@workId";
         }
         return(cn.Execute(sql, workInfo));
     }
 }
Beispiel #13
0
        public ActionResult getPage([FromBody] Model.WorkInfo page)
        {
            var result = DAL.WorkInfo.Instance.GetPage(page);

            if (result.Count() == 0)
            {
                return(Json(Result.Err("返回记录数为0")));
            }
            else
            {
                return(Json(Result.Ok(result)));
            }
        }
Beispiel #14
0
 public ActionResult Post([FromBody]Model.WorkInfo workInfo)
 {
     workInfo.recommend = "否";
     workInfo.workVerify = "待审核";
     workInfo.uploadTime = DateTime.Now;
     try
     {
         int n = DAL.WorkInfo.Instance.Add(workInfo);
         return Json(Result.Ok("发布作品成功", n));
     }
     catch(Exception ex)
     {
         if (ex.Message.ToLower().Contains("foreign key"))
             if (ex.Message.ToLower().Contains("username"))
                 return Json(Result.Err("合法用户才能添加记录");
Beispiel #15
0
        public ActionResult getMyPage([FromBody] Model.WorkInfo page)
        {
            if (page.userName == null)
            {
                page.userName = "";
            }
            var result = DAL.WorkInfo.Instance.GetMyPage(page);

            if (result.Count() == 0)
            {
                return(Json(Result.Err("返回记录数为0")));
            }
            else
            {
                return(Json(Result.Ok(result)));
            }
        }
Beispiel #16
0
 public ActionResult Put([FromBody] Model.WorkInfo workInfo)
 {
     workInfo.recommend = "否";
     workInfo.workVerify = "待审核";
     workInfo.uploadTime = DateTime.Now;
     try
     {
         int n = DAL.WorkInfo.Instance.Add(workInfo);
         if (n != 0)
             return Json(Result.Ok("修改作品成功", workInfo.workId));
         else
             return Json(Result.Err("workId不存在"));
     }
     catch (Exception ex)
     {
         if (ex.Message.ToLower().Contains("foreign key"))
             return Json(Result.Err("作品名称,作品图片,上传时间、作品审核情况、用户名、是否推荐不能为空"));
         else
             return Json(Result.Err(ex.Message));
     }
 }
Beispiel #17
0
 public ActionResult Put([FromBody]Model.WorkInfo workInfo) 
 {
     workInfo.recommend = "否";
     workInfo.workVerify = "待审核";
     workInfo.uploadTime = DateTime.Now;
     try
     {
         var n = DAL.WorkInfo.Instance.Update(workInfo);
         if (n != 0)
             return Json(Result.Ok("修改活动成功", workInfo.activityId));
         else
             return Json(Result.Err("workId不存在"));
     }
     catch (Exception ex)
     {
         if (ex.Message.ToLower().Contains("null"))
             return Json(Result.Err("活动名称、结束时间、活动图片、活动审核情况不能为空"));
         else
             return Json(Result.Err(ex.Message));
     }
 }
Beispiel #18
0
 public int UpdateImg(Model.WorkInfo workinfo)
 {
     using ()
     {
     }
 }