Esempio n. 1
0
        public ActionResult Edit(FileShareViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {

                    FileShareService.Update(model);
                    result.Message = "编辑文件共享成功!";
                    LogHelper.WriteLog("编辑文件共享成功");
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("编辑文件共享错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            ViewBag.Data_FileCateID = Utilities.GetSelectListData(
               FileCateService.GetALL().Where(x => x.PID.Equals(null))
               , x => x.ID, x => x.CateName, model.FileCateID, true, true);

            var departlist = DepartmentService.GetALL().Where(x => x.PID.Equals(null));

            var hasPermission = CookieHelper.CheckPermission("boss");
            if (!hasPermission)
            {
                var member = MemberService.Find(CookieHelper.MemberID);
                var depart = DepartmentService.Find(member.DepartmentID);
                if (depart.Level == 0)
                {
                    departlist = departlist.Where(x => x.ID == depart.ID);
                }
                else
                {
                    var rootCode = Utilities.GetRootCode(depart.Code, depart.Level);
                    departlist = departlist.Where(x => x.Code == rootCode);
                }
            }
            ViewBag.Data_DepartmentID = Utilities.GetSelectListData(
             departlist
               , x => x.ID, x => x.Name, model.DepartmentID, true, true);
            return View(model);
        }
Esempio n. 2
0
        public ActionResult Edit(int ID)
        {
            var entity = FileShareService.GetALL().Include(x => x.Member).Single(x => x.ID == ID);
            var model = new FileShareViewModel()
            {
                ID = entity.ID,
                Description = entity.Description,
                Name = entity.Name,
                FileCateID = entity.FileCateID,
                FilePath = entity.FilePath,
                DepartmentID = entity.DepartmentID
            };
            ViewBag.Data_FileCateID = Utilities.GetSelectListData(
              FileCateService.GetALL().Where(x => x.PID.Equals(null))
              , x => x.ID, x => x.CateName, model.FileCateID, true, true);

            var departlist = DepartmentService.GetALL().Where(x => x.PID.Equals(null));

            var hasPermission = CookieHelper.CheckPermission("boss");
            if (!hasPermission)
            {
                var member = MemberService.Find(CookieHelper.MemberID);
                var depart = DepartmentService.Find(member.DepartmentID);
                if (depart.Level == 0)
                {
                    departlist = departlist.Where(x => x.ID == depart.ID);
                }
                else
                {
                    var rootCode = Utilities.GetRootCode(depart.Code, depart.Level);
                    departlist = departlist.Where(x => x.Code == rootCode);
                }
            }
            ViewBag.Data_DepartmentID = Utilities.GetSelectListData(
             departlist
               , x => x.ID, x => x.Name, model.DepartmentID, true, true);

            return View(model);
        }