public JsonResult SetCompany(CompanyApply 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("请输入您的微信号")); } 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 = _companyApplyService.InsertAsync(model); return(Json(result)); }
public ActionResult AddCompanyApply(FormCollection frm) { CompanyApply companyApply = new CompanyApply() { CompanyName = frm["name"], Description = frm["detail"], EmailAddress = frm["emailApply"], Password = frm["sifre"], IsActive = true }; _companyApplyDal.Add(companyApply); return(RedirectToAction("Admin")); }
public bool InsertAsync(CompanyApply model) { using (var conn = DapperFactory.GetConnection()) { var fields = model.ToFields(removeFields: new List <string> { "Id", "MajorName", "MajorNameEn", "CompanyName", "CompanyNameEn" }); if (fields == null || fields.Count == 0) { return(false); } model.CreateTime = DateTime.Now; string sql = string.Format("insert into [CompanyApply] ({0}) values ({1});", string.Join(",", fields), string.Join(",", fields.Select(n => "@" + n))); return(conn.Execute(sql, model) > 0); } }
public bool InsertAsync(CompanyApply 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(_companyApplyRepository.InsertAsync(model)); }
public ActionResult Add(int id) { if (_companyApplyDal.GetByID(id) != null) { CompanyApply companyApply = _companyApplyDal.GetByID(id); ICompanyDal companyDal = InstanceFactory.GetInstance <ICompanyDal>(); Company company = new Company(); company.CompanyName = companyApply.CompanyName; company.Email = companyApply.EmailAddress; company.Password = companyApply.Password; company.PhotoPath = companyApply.PhotoPath; company.IsActive = true; companyDal.Add(company); companyApply.IsActive = false; _companyApplyDal.Update(companyApply); return(RedirectToAction("Index")); } else { return(RedirectToAction("Error404", "Error")); } }
public JsonResult SetCompany(CompanyApply 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("请输入您的微信号")); } 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 = _companyApplyService.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)); }