示例#1
0
        public JsonResult SubmitApply(MajorApply 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 = _majorApplyService.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));
        }
        public bool InsertAsync(MajorApply 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 [MajorApply] ({0}) values ({1});", string.Join(",", fields), string.Join(",", fields.Select(n => "@" + n)));
                return(conn.Execute(sql, model) > 0);
            }
        }
示例#3
0
        public bool InsertAsync(MajorApply 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(_majorApplyRepository.InsertAsync(model));
        }
示例#4
0
        public JsonResult SubmitApply(MajorApply 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 = _majorApplyService.InsertAsync(model);
            return(Json(result));
        }