public ActionResult Edit(int? id)
        {
            if (id == null || !id.HasValue)
            {
                TempData["HintMessage"] = new HintMessage { Content = string.Format("请确认用户是否存在") };
                return RedirectToAction("Index");
            }

            Core.Business.Account account = Core.Business.Account.Load(id.Value);

            if (account == null)
            {
                TempData["HintMessage"] = new HintMessage { Content = string.Format("请确认用户是否存在") };
                return RedirectToAction("Index");
            }

            AccountRoleEditModel model = new AccountRoleEditModel();

            model.Account = account;

            model.Roles = Role.GetAllRoles().Where(item => item.Status == 0).ToList().ToHashSet();

            model.Operations = new HashSet<Operation>();

            if (model.Account.Roles != null)
            {
                foreach (var role in model.Account.Roles)
                {
                    model.Operations = model.Operations.Union(role.Operations).ToHashSet();
                }
            }
            return View(model);
        }
 public ActionResult Create(Operation model)
 {
     if (model == null)
         throw new ArgumentNullException("the operation is null!!!");
     model.Save();
     TempData["HintMessage"] = new HintMessage { Content = String.Format("添加({0})操作成功!", model.Name) };
     return RedirectToAction("Index");
 }
 public ActionResult Create(Role model)
 {
     if (model == null)
         throw new ArgumentNullException("请检查输入!!");
     model.Save();
     TempData["HintMessage"] = new HintMessage { Content = string.Format("角色({0})添加成功", model.Name) };
     return RedirectToAction("Index");
 }
 public ActionResult Delete(int? id)
 {
     Operation model = null;
     if (id == null || !id.HasValue || (model = Operation.Load(id.Value)) == null)
         throw new ArgumentNullException("请检查是否存在该操作!!");
     model.DeleteOnSave();
     model.Save();
     TempData["HintMessage"] = new HintMessage { Content = String.Format("删除({0})操作成功!", model.Name) };
     return RedirectToAction("Index");
 }
 public ActionResult Create(Core.Business.Account model)
 {
     if (model == null)
     {
         TempData["HintMessage"] = new HintMessage { Content = "操作失败,系统发生了一个错误" };
         return RedirectToAction("Add");
     }
     CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
     model.Password = sh.ComputeMD5Hash(model.Password);
     model.Save();
     TempData["HintMessage"] = new HintMessage { Content = string.Format("人员({0})添加成功", model.Name) };
     return RedirectToAction("Index");
 }
 public ActionResult Delete(int? id)
 {
     Role role = null;
     if (id == null || !id.HasValue || (role = Role.Load(id.Value)) == null)
     {
         TempData["HintMessage"] = new HintMessage { Content = string.Format("角色({0})不存在,请检查", role.Name) };
         return RedirectToAction("Index");
     }
     role.DeleteOnSave();
     role.Save();
     TempData["HintMessage"] = new HintMessage { Content = string.Format("角色({0})删除成功", role.Name) };
     return RedirectToAction("Index");
 }
 public ActionResult SaveAuthority(int? id)
 {
     PicNode node = null;
     if (id == null || !id.HasValue || (node = PicNode.Load(id.Value)) == null)
         throw new HttpException("id is null !!! or the picnode is null!!!");
     if (node.Status == 1)
     {
         node.Status = 0;
     }
     else
     {
         node.Status = 1;
     }
     node.Save();
     TempData["HintMessage"] = new PhotoGallery.Infrastructure.Helpers.HintMessage { Content = "操作成功!!!" };
     return RedirectToAction("Authority");
 }
        public ActionResult Save(FolderDesc model)
        {
            if (model == null)
            {
                TempData["HintMessage"] = new PhotoGallery.Infrastructure.Helpers.HintMessage { Content = "操作失败,系统发生了一个错误" };
                return RedirectToAction("Index");
            }

            FolderDesc oringe = FolderDesc.Load(model.Id);
            PicNode node = PicNode.Load(model.Id);
            if (oringe != null)
            {
                oringe.KeyWord = model.KeyWord;
                oringe.Photographer = model.Photographer;
                oringe.StartDate = model.StartDate;
                oringe.EndDate = model.EndDate;
                //if (!string.IsNullOrEmpty(model.Leader))
                // oringe.Leader = model.Leader;

                oringe.Leader = Request.Form["LeaderInfo"];
                oringe.OtherLeader = model.OtherLeader;
                oringe.Guest = model.Guest;
                if (!string.IsNullOrEmpty(model.InnerLocation))
                    oringe.InnerLocation = model.InnerLocation;
                oringe.OuterLocation = model.OuterLocation;
                if (model.EventInfo != 0)
                {
                    oringe.EventInfo = model.EventInfo;
                }
                oringe.EventDesc = model.EventDesc;
                oringe.Save();
            }
            else
            {
                model.Save();
            }

            TempData["HintMessage"] = new PhotoGallery.Infrastructure.Helpers.HintMessage { Content = string.Format("为文件夹({0})添加描述信息成功", node != null ? node.Name : string.Empty) };

            return RedirectToAction("Index");
        }
        public ActionResult Detail(int? id)
        {
            if (id == null || !id.HasValue)
                throw new ArgumentException("the id is null!!!!");

            PicNode node = PicNode.Load(id.Value);
            if (node == null)
            {
                TempData["HintMessage"] = new PhotoGallery.Infrastructure.Helpers.HintMessage { Content = "操作失败,系统发生了一个错误" };
                return RedirectToAction("Index");
            }

            FolderDesc desc = FolderDesc.Load(id.Value);

            HomeDetailModel model = new HomeDetailModel(node, desc);

            return View(model);
        }
 public ActionResult Edit(int? id)
 {
     Role model = null;
     if (id == null || !id.HasValue || (model = Role.Load(id.Value)) == null)
     {
         TempData["HintMessage"] = new HintMessage { Content = "角色不存在,请检查" };
         return RedirectToAction("Index");
     }
     return View(model);
 }
        public ActionResult Update(Role model)
        {
            Role orgin = null;
            if (model == null || (orgin = Role.Load(model.Id)) == null)
            {
                TempData["HintMessage"] = new HintMessage { Content = string.Format("角色({0})不存在,请检查") };
                return RedirectToAction("Index");
            }

            orgin.Name = model.Name;
            orgin.Status = model.Status;
            orgin.Description = model.Description;
            orgin.Save();

            TempData["HintMessage"] = new HintMessage { Content = string.Format("角色({0})更新成功!", model.Name) };
            return RedirectToAction("Index");
        }
        public ActionResult Edit(int? id)
        {
            if (TempData["HintMessage"] != null)
            {
                ViewData["HintMessage"] = TempData["HintMessage"];
            }

            Core.Business.Account model;

            if (id == null || !id.HasValue || (model = Core.Business.Account.Load(id.Value)) == null)
            {
                TempData["HintMessage"] = new HintMessage { Content = "人员不存在,请确认人员是否存在", Type = HintMessageType.Error };
                return RedirectToAction("Index");
            }

            return View(model);
        }
        public ActionResult Delete(int? id)
        {
            if (id == null || id.HasValue || id.Value > 0)
            {
                TempData["HintMessage"] = new HintMessage { Content = String.Format("请确认该人员是否存在!!"), Type = HintMessageType.Error };
            }

            Core.Business.Account account = Core.Business.Account.Load(id.Value);

            if (account == null)
            {
                TempData["HintMessage"] = new HintMessage { Content = String.Format("请确认该人员是否存在!!"), Type = HintMessageType.Error };
            }
            else
            {
                account.DeleteOnSave();
                account.Save();
                TempData["HintMessage"] = new HintMessage { Content = String.Format("人员删除成功!!"), Type = HintMessageType.Error };

            }

            return RedirectToAction("Index");
        }
 public ActionResult Update(Operation model)
 {
     Operation operation = null;
     if (model == null || (operation = Operation.Load(model.Id)) == null)
         throw new ArgumentNullException("请检查输入!!");
     operation.Name = model.Name;
     operation.Controller = model.Controller;
     operation.Action = model.Action;
     operation.Status = model.Status;
     operation.Save();
     TempData["HintMessage"] = new HintMessage { Content = String.Format("修改({0})操作成功!", model.Name) };
     return RedirectToAction("Index");
 }
        public ActionResult Update(Core.Business.Account model)
        {
            if (TempData["HintMessage"] != null)
            {
                ViewData["HintMessage"] = TempData["HintMessage"];
            }
            Core.Business.Account oringe = null;

            if (model == null || (oringe = Core.Business.Account.Load(model.Id)) == null)
            {
                TempData["HintMessage"] = new HintMessage { Content = "人员不存在,请确认人员是否存在", Type = HintMessageType.Error };
                return RedirectToAction("Index");
            }

            oringe.Name = model.Name;
            oringe.Gender = model.Gender;
            oringe.Telephone = model.Telephone;
            oringe.Birthday = model.Birthday;
            oringe.Address = model.Address;

            oringe.Save();

            TempData["HintMessage"] = new HintMessage { Content = String.Format("人员({0})修改成功", model.Name) };

            return RedirectToAction("Index");
        }
        public ActionResult ReLogin(string reason)
        {
            if (string.IsNullOrEmpty(reason))
            {
                if (TempData["HintMessage"] != null)
                {
                    ViewData["HintMessage"] = TempData["HintMessage"];
                }
            }
            else
            {
                ViewData["HintMessage"] = new HintMessage { Content = !string.IsNullOrEmpty(reason) ? reason : "您已经退出!" };
            }

            return View("Login");
        }
        public ActionResult Login(Core.Business.Account model)
        {
            if (string.IsNullOrEmpty(model.LoginName) || string.IsNullOrEmpty(model.Password))
            {
                TempData["HintMessage"] = new HintMessage { Content = "登录失败,请检查用户名和密码是否匹配" };
                return this.ReLogin("登录失败,请检查用户名和密码是否匹配!");
            }
            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            string oldPwd = sh.ComputeMD5Hash(model.Password);
            Core.Business.Account account = Core.Business.Account.FindBy(model.LoginName.ToLower(), oldPwd.ToLower());
            if (account == null)
            {
                TempData["HintMessage"] = new HintMessage { Content = "登录失败,请检查用户名和密码是否匹配" };
                return this.ReLogin("登录失败,请检查用户名和密码是否匹配!");
            }
            else
            {
                PhotoGallery.Application.UserSession.OnlineAccount = account;
                TempData["HintMessage"] = new HintMessage { Content = string.Format("登录成功,{0},欢迎您的到来!", account.Name) };
                return RedirectToAction("Index", "Home");
            }
        }