Exemplo n.º 1
0
        public ActionResult Edit(Permission mode)
        {
            string id = mode.BusinessID;

            try
            {
                if (ModelState.IsValid)
                {
                    PermissionDao dao = new PermissionDao();


                    dao.Update(mode);
                    if (dao.Update(mode) > 0)
                    {
                        SetAlert("Cập nhật thành công", "success");
                        return(RedirectToAction("Index", "Permission", new { id = id }));
                    }
                    else
                    {
                        SetAlert("Không thành công", "danger");
                    }
                    return(RedirectToAction("Index", "Permission", new { id = id }));
                }
                else
                {
                    SetAlert("Không thành công", "danger");
                    return(RedirectToAction("Index", "Permission", new { id = id }));
                }
            }
            catch
            {
                return(RedirectToAction("Index", "Permission", new { id = mode.BusinessID }));
            }
        }
Exemplo n.º 2
0
        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));
        }