Beispiel #1
0
        public JsonResult SubmitApply(ProgramApply 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("请输入您的微信号"));
            }
            var result = new ResultBase();

            result.success = _programApplyService.InsertAsync(model);
            if (result.success)
            {
                result.success = _mailInfoService.SendMail("项目咨询", model.Country.GetDescription(), model.MajorId, model.Name, model.Phone, model.Email, model.Question,
                                                           new List <string>(), System.Web.HttpContext.Current.Server.MapPath("/"));
            }
            return(Json(result));
        }
Beispiel #2
0
        public bool InsertAsync(ProgramApply model)
        {
            using (var conn = DapperFactory.GetConnection())
            {
                var fields = model.ToFields(removeFields: new List <string> {
                    "Id", "MajorName", "MajorNameEn", "ProgramName", "ProgramNameEn", "ProgramType"
                });
                if (fields == null || fields.Count == 0)
                {
                    return(false);
                }

                model.CreateTime = DateTime.Now;

                string sql = string.Format("insert into [ProgramApply] ({0}) values ({1});", string.Join(",", fields), string.Join(",", fields.Select(n => "@" + n)));
                return(conn.Execute(sql, model) > 0);
            }
        }
        public bool InsertAsync(ProgramApply 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(_programApplyRepository.InsertAsync(model));
        }
Beispiel #4
0
        public JsonResult SubmitApply(ProgramApply 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("请输入您的微信号"));
            }
            var result = new ResultBase();

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