Пример #1
0
        public ActionResult Create(BlockDataRoleCreateModel model)
        {
            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SaveAccessLog("create");
            if (null == Session[this.SESSION_NAME_USERID])
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SetConnectionDB();

            RoleServices services = new RoleServices(this.DBConnection);

            int result = services.Create(model);

            if (services.ERROR != null)
            {
                FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt");
            }
            //*************************************XU LY VAN DE THONG BAO THANH CONG HAY THAT BAI********************
            this.GetLanguage();
            BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel();

            blockLang.BlockName = "block_role_create";
            blockLang.SetLanguage(this.LANGUAGE_OBJECT);
            Session["msg_text"] = blockLang.GetMessage(result);
            Session["msg_code"] = result;
            if (model.RoleId > 0 && result > 1)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_role_create.success_edit", this.LANGUAGE_OBJECT);
            }
            if (result == 0)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_role_create.error_business_1", this.LANGUAGE_OBJECT);
                //return RedirectToAction("Create?roleid=" + model.RoleId);
            }
            //*********************** INSERT OR EDIT SUCCESSFULLY**************************************************
            if (result > 0)
            {
                return(RedirectToAction("List"));
            }

            //*************************************************************************
            //BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel();
            //BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_role_create", this.LANGUAGE_OBJECT, blockLang);
            //blockModel.DataModel = model;
            //ViewData["BlockData"] = blockModel;
            //return View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml");

            TempData["data"] = model;
            return(RedirectToAction("Create"));
        }
Пример #2
0
        public ActionResult Delete()
        {
            this.SaveAccessLog("delete");
            if (Session["IsAdmin"] == null)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            string id     = this.HttpContext.Request["roleid"];
            int    output = 0;

            try
            {
                this.SetConnectionDB();



                RoleServices services = new RoleServices(this.DBConnection);
                if (services.ERROR != null)
                {
                    throw new Exception(services.ERROR);
                }
                output = services.Delete(Int32.Parse(id));
            }
            catch (Exception ex)
            {
                FileHelper.SaveFile(new { data = id, ERROR = ex }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt");
                output = -2;
            }
            //*************************************XU LY VAN DE THONG BAO THANH CONG HAY THAT BAI********************
            this.GetLanguage();
            BlockLangRoleCreateModel blockLang = new BlockLangRoleCreateModel();

            blockLang.BlockName = "block_role_list";
            blockLang.SetLanguage(this.LANGUAGE_OBJECT);

            Session["msg_code"] = output;
            if (output > 1)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_role_list.success_delete", this.LANGUAGE_OBJECT);
            }


            return(RedirectToAction("List"));
        }