コード例 #1
0
        public virtual void LoadPermission()
        {
            var permDao  = new PermissionDao();
            var permItem = permDao.GetByUser(WindowsId);

            if (permItem != null)
            {
                Role = permItem.Role;
            }
        }
コード例 #2
0
ファイル: UzivatelController.cs プロジェクト: thenracker/pdca
        public ActionResult Edit(int id, Uzivatel collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var dao = new UzivatelDao();
                    collection.WindowsId = collection.WindowsId.ToUpper();
                    dao.Update(collection);

                    var permDao  = new PermissionDao();
                    var permItem = permDao.GetByUser(collection);
                    if (collection.Role.Id == 0)
                    {
                        if (permItem != null)
                        {
                            permDao.Delete(permItem);
                        }
                    }
                    else
                    {
                        if (permItem == null)
                        {
                            permDao.Create(new Permission()
                            {
                                Role      = collection.Role,
                                WindowsId = collection.WindowsId
                            });
                        }
                        else if (permItem.Role.Id != collection.Role.Id)
                        {
                            permItem.Role.Id = collection.Role.Id;
                            permDao.Update(permItem);
                        }
                    }

                    TempData[MessagesHelper.Success] = Resources.UzivatelTexts.UserUpdated;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData[MessagesHelper.Warning] = "Zkontrolujte zadané údaje";
                }
            }
            catch
            {
                TempData[MessagesHelper.Warning] = "Zkontrolujte zadané údaje";
            }
            return(View(collection));
        }
コード例 #3
0
ファイル: UzivatelController.cs プロジェクト: thenracker/pdca
        public ActionResult Delete(int id)
        {
            var dao  = new UzivatelDao();
            var item = dao.GetById(id);

            if (item == null)
            {
                return(RedirectToAction("Index"));
            }
            var permDao  = new PermissionDao();
            var permItem = permDao.GetByUser(item);

            if (permItem != null)
            {
                permDao.Delete(permItem);
            }

            dao.Delete(item);
            TempData[MessagesHelper.Success] = Resources.UzivatelTexts.UserDeleted;
            return(RedirectToAction("Index"));
        }