Example #1
0
        public ActionResult DeleteLang_Confirm(ManageMenuLangModel model)
        {
            var strError = string.Empty;

            if (model.Id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            try
            {
                _accessRoleStore.DeleteLang(model.Id);

                //Clear cache
                MenuHelper.ClearAllMenuCache();
            }
            catch (Exception ex)
            {
                strError = ManagerResource.LB_SYSTEM_BUSY;

                logger.Error("Failed to get Delete Menu Lang because: " + ex.ToString());

                return(Json(new { success = false, message = strError }));
            }

            return(Json(new { success = true, message = ManagerResource.LB_DELETE_SUCCESS, title = ManagerResource.LB_NOTIFICATION, clientcallback = string.Format(" ShowMenuLang({0})", model.MenuId) }));
        }
Example #2
0
        public ActionResult DeleteLang()
        {
            ManageMenuLangModel model = new ManageMenuLangModel();
            var id      = Utils.ConvertToInt32(Request["Id"]);
            var groupId = Utils.ConvertToInt32(Request["MenuId"]);

            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            model.MenuId = groupId;
            model.Id     = id;

            return(PartialView("_DeleteLangInfo", model));
        }
Example #3
0
        public ActionResult ShowMenuLang(int id)
        {
            ManageMenuLangModel model = new ManageMenuLangModel();

            try
            {
                model.MenuId    = id;
                model.Languages = LanguagesProvider.GetListLanguages();
                model.MenuInfo  = _accessRoleStore.GetMenuDetail(id);
            }
            catch (Exception ex)
            {
                this.AddNotification("Failed to get data because: " + ex.ToString(), NotificationType.ERROR);
                PartialView("_Detail", model);
            }
            return(PartialView("_Detail", model));
        }
Example #4
0
        public ActionResult UpdateLang()
        {
            ManageMenuLangModel model = new ManageMenuLangModel();
            var id      = Utils.ConvertToInt32(Request["Id"]);
            var groupId = Utils.ConvertToInt32(Request["MenuId"]);

            if (groupId == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (id > 0)
            {
                model.IsUpdate = true;
            }

            try
            {
                model.Languages = LanguagesProvider.GetListLanguages();
                model.MenuId    = groupId;

                //Begin db transaction
                var info = _accessRoleStore.GetLangDetail(id);

                if (info != null)
                {
                    model.MenuId   = groupId;
                    model.Id       = info.Id;
                    model.LangCode = info.LangCode;
                    model.Title    = info.Title;
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed for Show UpdateLang form request: " + ex.ToString());
            }

            return(PartialView("../Menu/_UpdateLang", model));
        }
Example #5
0
        public ActionResult UpdateLang(ManageMenuLangModel model)
        {
            var msg       = ManagerResource.LB_OPERATION_SUCCESS;
            var isSuccess = false;

            if (!ModelState.IsValid)
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage + x.Exception));
                this.AddNotification(messages, NotificationType.ERROR);

                return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = messages }));
            }

            try
            {
                var code = 0;

                //Begin db transaction
                var data = new IdentityMenuLang();
                data.Id       = model.Id;
                data.MenuId   = model.MenuId;
                data.Title    = model.Title;
                data.LangCode = model.LangCode;

                if (model.Id > 0)
                {
                    //Update
                    code = _accessRoleStore.UpdateLang(data);

                    if (code == EnumCommonCode.Error)
                    {
                        return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = ManagerResource.LB_DUPLICATE_DATA, clientcallback = string.Format(" ShowMenuLang({0})", model.MenuId) }));
                    }

                    //Clear cache
                    MenuHelper.ClearAllMenuCache();
                }
                else
                {
                    //Add new
                    code = _accessRoleStore.AddNewLang(data);

                    if (code == EnumCommonCode.Error)
                    {
                        return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = ManagerResource.LB_DUPLICATE_DATA, clientcallback = string.Format(" ShowMenuLang({0})", model.MenuId) }));
                    }

                    //Clear cache
                    MenuHelper.ClearAllMenuCache();
                }

                isSuccess = true;
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed for UpdateLang request: " + ex.ToString());

                return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = NotifSettings.Error_SystemBusy }));
            }

            return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = msg, clientcallback = string.Format(" ShowMenuLang({0})", model.MenuId) }));
        }