コード例 #1
0
ファイル: ModuleForm.cs プロジェクト: junseong5019799/Team2
        private void Delete(object sender, EventArgs e)
        {
            if (((MainForm)this.MdiParent).ActiveMdiChild == this)
            {
                try
                {
                    string module_id = dataGridViewControl1.GetCheckIDs("MODULE_ID");

                    if (string.IsNullOrEmpty(module_id))
                    {
                        return;
                    }

                    if (moduleService.DeleteModule(module_id))
                    {
                        MessageBox.Show("정상적으로 삭제되었습니다.");
                        LoadData();
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }
コード例 #2
0
        //Delete a module.
        public ActionResult Delete(int id = 0)
        {
            ModuleService moduleService = new ModuleService();

            if (id == 0)
            {
                TempData["message"] = "Please select an entry.";
                return(RedirectToAction("Index"));
            }
            List <int> idList = new List <int>();

            idList.Add(id);
            moduleService.DeleteModule(idList);
            TempData["message"] = "Module has been deleted.";
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        protected override void OnSubmit()
        {
            var isNew = _page == null;

            if (isNew)
            {
                _page = new Page();
                _page.UploadFolder = Path.GetRandomFileName();
                _page.Position     = Page.Query.Count() + 1;
            }

            using (var conn = new NTGDBTransactional())
            {
                if (_page.Id == 0 || !_page.Name.Equals(Name))
                {
                    RedirectTo = Name.Replace(" ", "-").ToLower();
                }

                _page.Name            = Name;
                _page.HeroImage       = HeroImage;
                _page.MobileHeroImage = !string.IsNullOrEmpty(HeroImage) ? MobileHeroImage : null;

                /*The page with position 1 is the equivalent of home and should always have
                 * InMenu and as false because it has its own logic to appear in the top menu as the home link*/
                _page.InMenu       = _page.Position == 1 ? false : InMenu;
                _page.InBottomMenu = _page.Position == 1 ? false : InBottomMenu;
                //The home page cannot be inactive
                _page.Visible = _page.Position == 1 ? true : Visible;

                if (AdminLocked.HasValue)
                {
                    _page.AdminLocked = AdminLocked.Value;
                    if (!isNew)
                    {
                        NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                                SessionVariables.User,
                                                "Changed admin lock on page",
                                                _page.Id,
                                                _page.Name,
                                                null,
                                                null,
                                                conn);
                    }
                }

                _page.Save(conn);

                foreach (var module in _page.PageModules.OrderBy(pm => ModuleActions.OrderBy(ma => ma.Position).Select(ma => ma.Id).ToList().IndexOf(pm.Id)))
                {
                    var action = ModuleActions.SingleOrDefault(ma => ma.Id == module.Id);
                    if (action != null)
                    {
                        if (action.Delete)
                        {
                            ModuleService.DeleteModule(module, conn);
                            foreach (var nextAction in ModuleActions.Where(ma => ma.Position > action.Position))
                            {
                                nextAction.Position -= 1;
                            }
                            NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                                    SessionVariables.User,
                                                    "Deleted Module",
                                                    _page.Id,
                                                    _page.Name,
                                                    module.ModuleId,
                                                    ModuleType.Query.FirstOrDefault(mt => mt.Id == module.ModuleTypeId)?.Name,
                                                    conn);
                        }
                        else if (module.Position != action.Position)
                        {
                            module.Position = action.Position;
                            module.Save(conn);
                        }
                    }
                }

                NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                        SessionVariables.User,
                                        (isNew ? "Created" : "Editted") + " Page",
                                        _page.Id,
                                        _page.Name,
                                        null,
                                        null,
                                        conn);

                conn.Commit();
                ModuleService.RefreshModulesCache(_page.Id);
                AddMessage(Message.GLOBAL, new Message("Page " + Name + " successfully saved", MessageTypes.Success));
            }
        }
コード例 #4
0
ファイル: PageListFormModel.cs プロジェクト: dsvictorh/hazmat
        protected override void OnSubmit()
        {
            var deleteLog = string.Empty;
            var orderLog  = string.Empty;

            using (var conn = new NTGDBTransactional())
            {
                foreach (var page in _pages.OrderBy(p => PageActions.OrderBy(pa => pa.Position).Select(pa => pa.Id).ToList().IndexOf(p.Id)))
                {
                    var action = PageActions.SingleOrDefault(pa => pa.Id == page.Id);
                    if (action != null)
                    {
                        if (action.Delete)
                        {
                            var pageModules = PageModule.Query.Where(pm => pm.PageId == page.Id);
                            foreach (var pageModule in pageModules)
                            {
                                ModuleService.DeleteModule(pageModule, conn);
                            }

                            var cloudinaryResult = CloudinaryService.DeleteFolder(page.UploadFolder);
                            if (!string.IsNullOrEmpty(cloudinaryResult.error))
                            {
                                NTGLogger.LogError(HttpContext.Current.Request, "Cloudinary Error", cloudinaryResult.error, nameof(PageListFormModel), nameof(CloudinaryService.DeleteFolder), conn);
                            }
                            page.Delete(conn);
                            deleteLog += " - " + action.Id;
                            foreach (var nextAction in PageActions.Where(pa => pa.Position > action.Position))
                            {
                                nextAction.Position -= 1;
                            }
                        }
                        else if (page.Position != action.Position)
                        {
                            page.Position = action.Position;
                            page.Save(conn);
                            orderLog += " - " + action.Id;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(orderLog))
                {
                    NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                            SessionVariables.User,
                                            "Changed pages order " + orderLog,
                                            null,
                                            null,
                                            null,
                                            null,
                                            conn);
                }

                if (!string.IsNullOrEmpty(deleteLog))
                {
                    NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                            SessionVariables.User,
                                            "Deleted pages " + deleteLog,
                                            null,
                                            null,
                                            null,
                                            null,
                                            conn);
                }

                conn.Commit();
                AddMessage(Message.GLOBAL, new Message("Pages successfully saved", MessageTypes.Success));
            }
        }
コード例 #5
0
 protected override Task <int> RemoveAsync(int id)
 {
     return(moduleService.DeleteModule(id));
 }