예제 #1
0
        public ActionResult Edit(User model, HttpPostedFileBase file)
        {
            try
            {
                User user = new Entity.User();
                user = bllSession.IUserBLL.GetEntity(model.Id);
                if (file != null)
                {
                    string random = DateHelper.GetTimeStamp();
                    string root = "~/UserPhoto/";
                    var phicyPath = HostingEnvironment.MapPath(root);
                    if (!Directory.Exists(phicyPath))
                    {
                        Directory.CreateDirectory(phicyPath);
                    }
                    file.SaveAs(phicyPath + random + Path.GetExtension(file.FileName));
                    user.Photo = "/UserPhoto/" + random + Path.GetExtension(file.FileName);
                }
                user.Phone = model.Phone;
                user.QQ = model.QQ;
                user.Remark = model.Remark;
                user.Program = model.Program;
                user.Address = model.Address;

                bllSession.IUserBLL.Update(user);
                log.Info(new LogContent(model.Username + "用户修改了资料", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
                return Redirect("/User/Show/" + model.Id);
            }
            catch
            {
                log.Error(new LogContent("用户修改资料出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()));
                ModelState.AddModelError("", "用户修改资料出错!");
            }
            return View();
        }
예제 #2
0
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);
            if (requestContext.HttpContext.User.Identity.IsAuthenticated)
            {
                CurrentUser = BLLSessionFactory.GetBLLSession().IUserBLL.GetUserByName(User.Identity.Name.Trim());
            }

            ViewBag.CurrentUser = CurrentUser;
        }
예제 #3
0
 public ActionResult Edit(User model)
 {
     try
     {
         User user = bllSession.IUserBLL.GetEntity(model.Id);
         user.Username = model.Username;
         user.Email = model.Email;
         user.Phone = model.Phone;
         user.Photo = model.Photo;
         user.QQ = model.QQ;
         bllSession.IUserBLL.Update(user);
         return RedirectToAction("Index");
     }
     catch
     {
         log.Error(new LogContent("修改用户出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()));
         return View(model);
     }
 }
예제 #4
0
 public Video()
 {
     User = new User();
     Course = new Course();
 }
예제 #5
0
 public ActionResult Login(string Username, string Password, string ReturnUrl)
 {
     AjaxModel model = new AjaxModel();
     IBLL.IUserBLL bll = BLLSessionFactory.GetBLLSession().IUserBLL;
     User user = new User();
     Password = Encryt.GetMD5(Password.Trim());
     user = bll.Login(Username.Trim(), Password);
     if (user == null)
     {
         model.Data = user;
         model.Msg = "用户名或者密码不正确!";
         model.Statu = "err";
     }
     else
     {
         FormsAuthentication.SetAuthCookie(Username.Trim(), false);
         model.Data = user;
         model.Statu = "ok";
         model.BackUrl = ReturnUrl == null ? "/Home/Index" : ReturnUrl;
         log.Info(new LogContent(Username + ":登陆", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
     }
     return Json(model);
 }