Exemplo n.º 1
0
        public ActionResult ForgotPasswordApply(UserPasswordInfo info, HttpPostedFileBase image)
        {
            SystemDbContext db = new SystemDbContext();
            if (ModelState.IsValid)
            {
                //UserPasswordInfo info = new UserPasswordInfo();
                db.UserPasswordInfos.Add(info);
                if (image != null)
                {
                    info.BusinessLicenseType = image.ContentType;//获取图片类型
                    //view.BusinessLicence = new byte[image.ContentLength];//新建一个长度等于图片大小的二进制地址
                    // image.InputStream.Read(view.BusinessLicence, 0, image.ContentLength);//将image读取到Logo中
                    info.BusinessLicense = new byte[image.ContentLength];
                    image.InputStream.Read(info.BusinessLicense, 0, image.ContentLength);
                }

                DateTime time = DateTime.Now;

                /*利用Expression表达式树可以解决:LINQ to Entities 不识别方法“System.DateTime AddMinutes(Double)*/
                Expression<Func<UserPasswordInfo, bool>> where = p => p.UserName == info.UserName && (p.SubmitTime.AddMinutes(2) >= time);
                // var item = from p in db.UserPasswordInfos where (p.UserName == info.UserName && (p.SubmitTime.AddMinutes(2)<=time)) select p;
                var item = db.UserPasswordInfos.Where(where.Compile()).ToList();
                if (item.Count() == 0)
                {
                    /*审核状态字段*/
                   // info.AuditStatus = "ture";
                    info.SubmitTime = time;
                    db.SaveChanges();
                   // return RedirectToAction("ForgotPasswordInfo");
                    return RedirectToAction("ForgotPassword");
                }
                else
                    return RedirectToAction("ForgotPasswordInfoError");
            }
            return View(info);
        }
Exemplo n.º 2
0
 /*获取图片*/
 public FileContentResult GetImage()
 {
     //  SystemDbContext db = new SystemDbContext();
     UserPasswordInfo info = new UserPasswordInfo();
     if (info != null)
     {
         return File(info.BusinessLicense, info.BusinessLicenseType);//File方法直接将二进制转化为指定类型了。
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 3
0
 public ActionResult ForgotPasswordApply()
 {
     UserPasswordInfo view = new UserPasswordInfo();
     return View(view);
 }