Ejemplo n.º 1
0
        public bool InsertAsync(WorksComment model)
        {
            using (var conn = DapperFactory.GetConnection())
            {
                var fields = model.ToFields(removeFields: new List <string> {
                    "Id", "MajorName", "MajorNameEn"
                });
                if (fields == null || fields.Count == 0)
                {
                    return(false);
                }

                model.CreateTime = DateTime.Now;

                string sql = string.Format("insert into [WorksComment] ({0}) values ({1});", string.Join(",", fields), string.Join(",", fields.Select(n => "@" + n)));
                return(conn.Execute(sql, model) > 0);
            }
        }
Ejemplo n.º 2
0
        public bool InsertAsync(WorksComment model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model不能为null");
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                throw new ArgumentNullException("姓名不能为空");
            }

            if (string.IsNullOrEmpty(model.Phone))
            {
                throw new ArgumentNullException("手机不能为空");
            }

            return(_worksCommentRepository.InsertAsync(model));
        }
Ejemplo n.º 3
0
        public JsonResult Comment(WorksComment model)
        {
            if (model == null)
            {
                return(Error("参数错误。"));
            }

            if (model.MajorId == 0)
            {
                return(Error("请选择您计划学的专业"));
            }
            if (string.IsNullOrEmpty(model.Name))
            {
                return(Error("请输入您的姓名"));
            }
            if (string.IsNullOrEmpty(model.Phone))
            {
                return(Error("请输入您的微信号"));
            }
            if (string.IsNullOrEmpty(model.Email))
            {
                return(Error("请输入您的邮箱地址"));
            }
            List <string>          fileList = new List <string>();
            HttpFileCollectionBase files    = Request.Files;

            if (files != null)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    HttpPostedFileBase file = files[i];
                    //1-3个作品
                    if (i == 0)
                    {
                        string uploadResult = UploadHelper.Process(file.FileName, file.InputStream);
                        if (!string.IsNullOrEmpty(uploadResult))
                        {
                            model.ImgUrlA = uploadResult;
                            fileList.Add(uploadResult);
                        }
                    }
                    if (i == 1)
                    {
                        string uploadResult = UploadHelper.Process(file.FileName, file.InputStream);
                        if (!string.IsNullOrEmpty(uploadResult))
                        {
                            model.ImgUrlB = uploadResult;
                            fileList.Add(uploadResult);
                        }
                    }
                    if (i == 2)
                    {
                        string uploadResult = UploadHelper.Process(file.FileName, file.InputStream);
                        if (!string.IsNullOrEmpty(uploadResult))
                        {
                            model.ImgUrlC = uploadResult;
                            fileList.Add(uploadResult);
                        }
                    }
                }
            }
            var result = new ResultBase();

            result.success = _worksCommentService.InsertAsync(model);
            if (result.success)
            {
                result.success = _mailInfoService.SendMail("作品评析", model.Country.GetDescription(), model.MajorId, model.Name, model.Phone, model.Email, "",
                                                           fileList, System.Web.HttpContext.Current.Server.MapPath("/"));
            }
            return(Json(result));
        }
Ejemplo n.º 4
0
        public JsonResult Comment(WorksComment model)
        {
            if (model == null)
            {
                return(Error("参数错误。"));
            }

            if (model.MajorId == 0)
            {
                return(Error("请选择您计划学的专业"));
            }
            if (string.IsNullOrEmpty(model.Name))
            {
                return(Error("请输入您的姓名"));
            }
            if (string.IsNullOrEmpty(model.Phone))
            {
                return(Error("请输入您的微信号"));
            }
            if (string.IsNullOrEmpty(model.Email))
            {
                return(Error("请输入您的邮箱地址"));
            }
            HttpFileCollectionBase files = Request.Files;

            if (files != null)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    HttpPostedFileBase file = files[i];
                    //1-3个作品
                    if (i == 0)
                    {
                        string uploadResult = UploadHelper.Process(file.FileName, file.InputStream);
                        if (!string.IsNullOrEmpty(uploadResult))
                        {
                            model.ImgUrlA = uploadResult;
                        }
                    }
                    if (i == 1)
                    {
                        string uploadResult = UploadHelper.Process(file.FileName, file.InputStream);
                        if (!string.IsNullOrEmpty(uploadResult))
                        {
                            model.ImgUrlB = uploadResult;
                        }
                    }
                    if (i == 2)
                    {
                        string uploadResult = UploadHelper.Process(file.FileName, file.InputStream);
                        if (!string.IsNullOrEmpty(uploadResult))
                        {
                            model.ImgUrlC = uploadResult;
                        }
                    }
                }
            }
            var result = new ResultBase();

            result.success = _worksCommentService.InsertAsync(model);
            return(Json(result));
        }