public ActionResult Create() { this.SaveAccessLog("create"); if (null == Session[this.SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } if (Session["IsAdmin"] is false) { return(RedirectToAction("Logout", "Home")); } this.SetCommonData(); ViewData["pagename"] = "department_create"; ViewData["action_block"] = "Departments/block_department_create"; ViewData["data-form"] = TempData["data"]; string departId = (Request.QueryString["departid"] == null ? "0" : Request.QueryString["departid"].ToString()); this.SetConnectionDB(); DepartmentServices services = new DepartmentServices(this.DBConnection); EntityDepartmentModel model = new EntityDepartmentModel(); if (ViewData["data-form"] != null) { model = (EntityDepartmentModel)ViewData["data-form"]; } else { model = services.GetEntityById(Int32.Parse(departId)); } //EntityDepartmentModel modelResponse = services.GetEntityById(Int32.Parse(departId)); this.GetLanguage(); if (model.DepartId > 0) { ViewData["pagename"] = "department_edit"; } if (services.ERROR != null) { FileHelper.SaveFile(new { data = model, ERROR = services.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } BlockDepartmentCreateLangModel blockLang = new BlockDepartmentCreateLangModel(); BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_department_create", this.LANGUAGE_OBJECT, blockLang); blockModel.DataModel = model; ViewData["BlockData"] = blockModel; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }
public ActionResult Delete() { this.SaveAccessLog("delete"); if (Session["IsAdmin"] == null) { return(RedirectToAction("Logout", "Home")); } string id = this.HttpContext.Request["departid"]; int output = 0; try { this.SetConnectionDB(); DepartmentServices services = new DepartmentServices(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(); BlockDepartmentCreateLangModel blockLang = new BlockDepartmentCreateLangModel(); blockLang.BlockName = "block_department_list"; blockLang.SetLanguage(this.LANGUAGE_OBJECT); Session["msg_code"] = output; if (output > 1) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_department_list.success_delete", this.LANGUAGE_OBJECT); } return(RedirectToAction("List")); }
public ActionResult Create(EntityDepartmentModel model) { if (null == Session[this.SESSION_NAME_USERID]) { return(RedirectToAction("Login", "Home")); } if (Session["IsAdmin"] == null) { return(RedirectToAction("Logout", "Home")); } this.SetConnectionDB(); this.GetLanguage(); int output = 0; if (model.Code == null) { Session["msg_code"] = -1; Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_department_create.error_code"); TempData["data"] = model; return(RedirectToAction("Create")); } model.Code = model.Filter01.Substring(0, 2); DepartmentServices departServices = new DepartmentServices(this.DBConnection); output = departServices.CreateDepart(model); /****************************************RESPONSE FAILE OR SUCCESS******************************************/ //this.GetLanguage(); BlockDepartmentCreateLangModel blockLang = new BlockDepartmentCreateLangModel(); blockLang.BlockName = "block_department_create"; blockLang.SetLanguage(this.LANGUAGE_OBJECT); Session["msg_text"] = blockLang.GetMessage(output); Session["msg_code"] = output; if (departServices.ERROR != null) { BI_Project.Helpers.FileHelper.SaveFile(departServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt"); } if (model.DepartId > 0 && output > 0) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_department_create.success_edit", this.LANGUAGE_OBJECT); } if (output == 0) { Session["msg_text"] = blockLang.GetLangByPath("messages.block_department_create.error_business_1", this.LANGUAGE_OBJECT); //return RedirectToAction("Create?roleid=" + model.RoleId); } if (output > 0) { return(RedirectToAction("List")); } TempData["data"] = model; return(RedirectToAction("Create")); }