コード例 #1
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));
        }
コード例 #2
0
        public ActionResult Delete(long id)
        {
            try
            {
                // TODO: Add delete logic here

                PermissionDao bdDao = new PermissionDao();

                bdDao.Delete(id);
                // SetAlert("Xóa thành công", "success");
                return(RedirectToAction("Index"));
            }
            catch
            {
                // SetAlert("Không xóa được", "danger");
                return(View());
            }
        }
コード例 #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"));
        }