コード例 #1
0
ファイル: MenusController.cs プロジェクト: chipdlk/THD
        public ActionResult SaveItem(MenusModel model)
        {
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int        IdDC           = Int32.Parse(MyModels.Decode(model.Item.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            MenusModel data           = model;

            if (ModelState.IsValid)
            {
                if (model.Item.Id == IdDC)
                {
                    model.Item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    MenusService.SaveItem(model.Item);
                    if (model.Item.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index", new { IdCoQuan = model.Item.IdCoQuan }));
                }
            }
            data.ListType = MenusService.GetListType();
            return(View(data));
        }
        public PartialViewResult  HeaderPartial()
        {
            var menus = new MenusModel().getMenus();

            ViewBag.Menu = menus;
            return(PartialView());
        }
コード例 #3
0
ファイル: MenusController.cs プロジェクト: chipdlk/THD
        public IActionResult SaveItem(string Id = null, int IdCoQuan = 1)
        {
            MenusModel data           = new MenusModel();
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();

            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchMenus()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = "", IdCoQuan = IdCoQuan
            };
            data.ListItemsArticle       = ArticlesService.GetListStaticArticle();
            data.ListType               = MenusService.GetListType();
            data.ListCategoriesArticles = CategoriesArticlesService.GetList();
            data.ListCategoriesProducts = ProductsCategoriesService.GetList();
            data.ListItemsMenus         = MenusService.GetListItems(true, IdCoQuan);

            if (IdDC == 0)
            {
                data.Item = new Menus();
            }
            else
            {
                data.Item = MenusService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
コード例 #4
0
        public PartialViewResult ChildMenuPartial(int parentId)
        {
            var childMenus = new MenusModel().getChildMenus(parentId);

            ViewBag.childCount = childMenus.Count();
            ViewBag.childMenus = childMenus;
            return(PartialView("ChildMenuPartial"));
        }
コード例 #5
0
        public ActionResult Products(int?id)
        {
            var menus = new MenusModel().getLeftMenu();

            ViewBag.Categories = menus;
            ViewBag.Name       = new MenusModel().getNameMenuById(id);
            return(View());
        }
コード例 #6
0
 public ActionResult Edit(MenusModel model)
 {
     if (model.Edit())
     {
         return(Json(new JavaScriptSerializer().Serialize(model)));
     }
     return(Content("-1"));
 }
        // GET: Menu
        public PartialViewResult LeftChildMenusPartial(int parentId)
        {
            var leftChildMenus = new MenusModel().getLeftChildMenus(parentId);

            ViewBag.categoryId         = parentId;
            ViewBag.leftChildMenuCount = leftChildMenus.Count();
            ViewBag.leftChildMenus     = leftChildMenus;
            return(PartialView("LeftChildMenusPartial"));
        }
        public PartialViewResult ChildMenuMobilePartial(int parentId)
        {
            var ChildMenuMobile = new MenusModel().getLeftChildMenus(parentId);

            ViewBag.categoryId           = parentId;
            ViewBag.ChildMenuMobileCount = ChildMenuMobile.Count();
            ViewBag.ChildMenuMobile      = ChildMenuMobile;
            return(PartialView("ChildMenuMobilePartial"));
        }
        public PartialViewResult GrandchildrenPartial(int parentId)
        {
            var Grandchildren = new MenusModel().getLeftChildMenus(parentId);

            ViewBag.categoryId         = parentId;
            ViewBag.GrandchildrenCount = Grandchildren.Count();
            ViewBag.Grandchildren      = Grandchildren;
            return(PartialView("GrandchildrenPartial"));
        }
コード例 #10
0
 public HttpResponseMessage Post([FromBody] MenusModel item)
 {
     //TODO: varificar por que esto no esta funcionando...
     _process.Save(Token: item.Token, UpdatedId: UpdatedId,
                   Menu: item.Menu, Help: item.Help, FilePage: item.FilePage,
                   IsActive: item.IsActive, IsHorizontal: item.IsHorizontal,
                   IsVertical: item.IsVertical, ParentId: item.ParentId,
                   IsParent: item.IsParent, IsParentMenu: item.IsParentMenu, IsAutorization: item.IsAutorization, Alias: item.Alias);
     return(new HttpResponseMessage(HttpStatusCode.OK));
 }
コード例 #11
0
        public ActionResult Index()
        {
            MenusModel model = GetModelFromSession();

            if (model == null)
            {
                model = RetrieveMenus();
            }

            return(View(model));
        }
コード例 #12
0
        public ResResultModel SaveMenus(MenusModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, "未获取到任何参数"));
                }
                if (string.IsNullOrWhiteSpace(model.Title))
                {
                    return(ResResult.Response(false, "菜单名称不能为空字符串"));
                }
                var Id       = Guid.Empty;
                var parentId = Guid.Empty;
                if (model.Id != null && !string.IsNullOrWhiteSpace(model.Id.ToString()))
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                if (model.ParentId != null && !string.IsNullOrWhiteSpace(model.ParentId.ToString()))
                {
                    Guid.TryParse(model.ParentId.ToString(), out parentId);
                }

                var appBll = new Application();
                var appId  = appBll.GetApplicationId(Membership.ApplicationName);

                var bll    = new Menus();
                int effect = 0;

                var modelInfo = new MenusInfo(Guid.Parse(appId.ToString()), Id, parentId, model.IdStep, model.Title, model.Url, model.Descr, "*", "", model.Sort, DateTime.Now);

                if (Id.Equals(Guid.Empty))
                {
                    modelInfo.Id     = Guid.NewGuid();
                    modelInfo.IdStep = (modelInfo.Id + "," + modelInfo.IdStep).Trim(',');
                    effect           = bll.InsertByOutput(modelInfo);
                }
                else
                {
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, "操作失败,数据库操作异常"));
                }

                return(ResResult.Response(true, "操作成功", modelInfo.Id));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, "操作异常:" + ex.Message + ""));
            }
        }
コード例 #13
0
 public ActionResult Edit(MenusModel model)
 {
     model.sesion = SessionDB.start(Request, Response, false, model.db, SESSION_BEHAVIOR.AJAX);
     if (model.sesion == null)
     {
         return(Content(string.Empty));
     }
     if (model.Edit())
     {
         model.Dispose();
         return(Json(new JavaScriptSerializer().Serialize(model)));
     }
     return(Content("-1"));
 }
コード例 #14
0
        private string ConsultaIdsMenu()
        {
            MenusModel model = new MenusModel();
            Dictionary <int, string> dict = new Dictionary <int, string>();

            dict.Add(0, "Principal");
            model.ConsultaIdsMenu(dict);

            StringBuilder sb = new StringBuilder();

            foreach (KeyValuePair <int, string> item in dict)
            {
                sb.Append("<option value=\"").Append(item.Key).Append("\">").Append(item.Value).Append("</option>  ");
            }
            return(sb.ToString());
        }
コード例 #15
0
        private string ConsultaIdsPermisos()
        {
            MenusModel model = new MenusModel();
            Dictionary <long, string> dict = new Dictionary <long, string>();

            dict.Add(0, "Sin permiso");
            model.ConsultaIdsPermisos(dict);

            StringBuilder sb = new StringBuilder();

            foreach (KeyValuePair <long, string> item in dict)
            {
                sb.Append("<option value=\"").Append(item.Key).Append("\">").Append(item.Key).Append(" - ").Append(item.Value).Append("</option>  ");
            }
            return(sb.ToString());
        }
コード例 #16
0
 public ActionResult Delete(MenusModel model)
 {
     try
     {
         if (model.Delete())
         {
             return(Json(new { msg = Notification.Succes("Ficha eliminada con exito: " + model.Nombre) }));
         }
         else
         {
             return(Json(new { msg = Notification.Error("Error al eliminar: " + model.Nombre) }));
         }
     }
     catch (Exception e)
     {
         return(Json(new { msg = Notification.Error(e.Message) }));
     }
 }
コード例 #17
0
 public ActionResult Save(MenusModel model)
 {
     try
     {
         model.sesion = SessionDB.start(Request, Response, false, model.db);
         if (model.Save())
         {
             return(Json(new { msg = Notification.Succes("Ficha guardada con exito: " + model.Nombre) }));
         }
         else
         {
             return(Json(new { msg = Notification.Error(" Erro al Guardar ficha: " + model.Nombre) }));
         }
     }
     catch (Exception e)
     {
         return(Json(new { msg = Notification.Error(e.Message) }));
     }
 }
コード例 #18
0
 public ActionResult Add(MenusModel model)
 {
     model.sesion = SessionDB.start(Request, Response, false, model.db);
     try
     {
         if (model.Add())
         {
             return(Json(new { msg = Notification.Succes("Ficha agregada con exito: " + model.Nombre) }));
         }
         else
         {
             return(Json(new { msg = Notification.Error(" Erro al agregar: " + model.Nombre) }));
         }
     }
     catch (Exception e)
     {
         return(Json(new { msg = Factory.Notification.Error(e.Message) }));
     }
 }
コード例 #19
0
        private MenusModel RetrieveMenus()
        {
            var model      = new MenusModel();
            var lunchMenus = new List <LunchMenu>();

            var dishes = _repository.GetThisWeekDishes();

            foreach (var dishGroup in dishes.GroupBy(d => d.RestaurantId))
            {
                var restaurant = Restaurant.GetById(dishGroup.Key);
                lunchMenus.Add(new LunchMenu(restaurant, dishGroup));
            }

            model.LunchMenus = lunchMenus.OrderBy(lm => lm.Restaurant.Id);

            System.Web.HttpContext.Current.Application.Lock();
            System.Web.HttpContext.Current.Application["Model"] = model;
            System.Web.HttpContext.Current.Application.UnLock();

            return(model);
        }
コード例 #20
0
ファイル: MenusController.cs プロジェクト: chipdlk/THD
        public IActionResult Index([FromQuery] SearchMenus dto)
        {
            int        TotalItems     = 0;
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            MenusModel data           = new MenusModel()
            {
                SearchData = dto
            };

            data.ListItems    = MenusService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            data.ListDMCoQuan = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            data.Pagination = new Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };

            return(View(data));
        }
コード例 #21
0
        // GET: Fichas
        public ActionResult Start()
        {
            MenusModel model  = new MenusModel();
            SessionDB  sesion = SessionDB.start(Request, Response, false, model.db);

            try
            {
                Main view = new Main();
                ViewBag.MainUser = view.CreateMenuInfoUser(sesion);
                // ViewBag.Main = view.createMenu(24, 26, sesion);
                ViewBag.Main = view.createMenu("Administración", "Fichas", sesion);

                //Intercom
                ViewBag.User     = sesion.nickName.ToString();
                ViewBag.Email    = sesion.nickName.ToString();
                ViewBag.FechaReg = DateTime.Today;

                ViewBag.DataTable = CreateDataTable(10, 1, null, "PADRE", "ASC", sesion);

                String[] scripts = { "js/Administracion/Fichas.js" };
                Scripts.SCRIPTS = scripts;
                ViewBag.Scripts = Scripts.addScript();

                ViewBag.PadreOptionsHTML     = ConsultaIdsMenu();
                ViewBag.PkPermisoOptionsHTML = ConsultaIdsPermisos();

                Log.write(this, "Start", LOG.CONSULTA, "Ingresa a pantalla Fichas", sesion);

                return(View());
            }
            catch (Exception e)
            {
                ViewBag.Notification = Notification.Error(e.Message);
                Log.write(this, "Start", LOG.ERROR, "Ingresa a pantalla Fichass" + e.Message, sesion);

                return(View());
            }
        }
コード例 #22
0
        public ActionResult Approx()
        {
            var markovChains = this.GetMarkovChains();

            var lunchMenus = new List <LunchMenu>();

            for (int i = 0; i < markovChains.Count; i++)
            {
                var    wordCount   = 3 + _randomizer.Next(0, 5);
                string description = markovChains[i].GenerateSentence(wordCount, 15);
                var    dishes      = new List <Dish> {
                    new Dish(description, DateTime.Today, 1)
                };

                lunchMenus.Add(new LunchMenu(Restaurant.GetById(i + 1), dishes));
            }

            var model = new MenusModel {
                LunchMenus = lunchMenus
            };

            return(View(model));
        }
コード例 #23
0
 public ActionResult Delete(MenusModel model)
 {
     try
     {
         model.sesion = SessionDB.start(Request, Response, false, model.db, SESSION_BEHAVIOR.AJAX);
         if (model.sesion == null)
         {
             return(Content(string.Empty));
         }
         if (model.Delete())
         {
             return(Json(new { msg = Notification.Succes("Menu eliminado con exito: " + model.Nombre) }));
         }
         else
         {
             return(Json(new { msg = Notification.Error("Error al eliminar: " + model.Nombre) }));
         }
     }
     catch (Exception e)
     {
         return(Json(new { msg = Notification.Error(e.Message) }));
     }
 }
コード例 #24
0
        // GET: Menus
        public ActionResult Start()
        {
            MenusModel model  = new MenusModel();
            SessionDB  sesion = SessionDB.start(Request, Response, false, model.db);

            try
            {
                Main view = new Main();
                ViewBag.MainUser = view.CreateMenuInfoUser(sesion);
                // ViewBag.Main = view.createMenu(24, 26, sesion);
                ViewBag.Main = view.createMenu("Administración", "Menu", sesion);

                ViewBag.DataTable = CreateDataTable(10, 1, null, "PADRE", "ASC", sesion);
                ViewBag.Scripts   = Scripts.addScript() + Scripts.setPrivileges(Privileges, sesion);

                if (!sesion.permisos.havePermission(Privileges[0].Permiso))
                {
                    return(View(Factory.View.NotAccess));
                }

                ViewBag.PadreOptionsHTML     = ConsultaIdsMenu();
                ViewBag.PkPermisoOptionsHTML = ConsultaIdsPermisos();
                ViewBag.OrdenOptionsHTML     = buildOptionsHTML();

                Log.write(this, "Start", LOG.CONSULTA, "Ingresa a pantalla Menus. 'hola'", sesion);

                return(View());
            }
            catch (Exception e)
            {
                ViewBag.Notification = Notification.Error(e.Message);
                Log.write(this, "Start", LOG.ERROR, "Ingresa a pantalla Menuss" + e.Message, sesion);

                return(View());
            }
        }
コード例 #25
0
        public ActionResult Refresh()
        {
            MenusModel model = RetrieveMenus();

            return(View("Index", model));
        }
コード例 #26
0
        // GET: Navigation
        //FreshFoodEntities db = new FreshFoodEntities();
        public PartialViewResult NavigationPartial()
        {
            var menus = new MenusModel().getMenus();

            return(PartialView(menus));
        }
コード例 #27
0
ファイル: SecurityService.cs プロジェクト: qq283335746/Asset
        public ResResultModel SaveMenus(MenusModel model)
        {
            try
            {
                if (!HttpContext.Current.User.IsInRole("Administrators"))
                {
                    throw new ArgumentException(MC.Role_InvalidError);
                }

                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError));
                }
                if (string.IsNullOrWhiteSpace(model.Title))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError));
                }
                var Id       = Guid.Empty;
                var parentId = Guid.Empty;
                if (model.Id != null && !string.IsNullOrWhiteSpace(model.Id.ToString()))
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                if (model.ParentId != null && !string.IsNullOrWhiteSpace(model.ParentId.ToString()))
                {
                    Guid.TryParse(model.ParentId.ToString(), out parentId);
                }

                var appBll = new Applications();
                var appId  = appBll.GetAspnetAppId(Membership.ApplicationName);

                var bll    = new SiteMenus();
                int effect = 0;

                var modelInfo = new SiteMenusInfo(Guid.Parse(appId.ToString()), Id, parentId, model.IdStep, model.Title, model.Url, model.Descr, model.Sort, DateTime.Now);

                if (Id.Equals(Guid.Empty))
                {
                    //MenusDataProxy.ValidateAccess((int)EnumData.EnumOperationAccess.新增, true);

                    modelInfo.Id     = Guid.NewGuid();
                    modelInfo.IdStep = (modelInfo.Id + "," + modelInfo.IdStep).Trim(',');
                    effect           = bll.InsertByOutput(modelInfo);
                }
                else
                {
                    //MenusDataProxy.ValidateAccess((int)EnumData.EnumOperationAccess.编辑, true);
                    var oldInfo = bll.GetModel(Id);
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, "操作失败,数据库操作异常"));
                }

                return(ResResult.Response(true, "操作成功", modelInfo.Id));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, "操作异常:" + ex.Message + ""));
            }
        }
コード例 #28
0
        public virtual async Task <ActionResult> MenuMal()
        {
            var model = new MenusModel
            {
                Items = new List <MenusModel> {
                    new MenusModel {
                        Name = "Anne Rice", Items = new List <MenusModel> {
                            new MenusModel {
                                Name = "Entrevista con el vampiro"
                            },
                            new MenusModel {
                                Name = "Lestat el vampiro"
                            },
                            new MenusModel {
                                Name = "La reina de los condenados"
                            },
                            new MenusModel {
                                Name = "El ladrón de cuerpos"
                            },
                            new MenusModel {
                                Name = "Memnoch el diablo"
                            },
                            new MenusModel {
                                Name = "Armand el vamipro"
                            },
                            new MenusModel {
                                Name = "Merrick"
                            },
                            new MenusModel {
                                Name = "Sangre y oro"
                            },
                            new MenusModel {
                                Name = "El santuario"
                            },
                            new MenusModel {
                                Name = "Príncipe Lestat"
                            },
                            new MenusModel {
                                Name = "Príncipe Lestat y los Reinos de la Atlántida"
                            }
                        }
                    },
                    new MenusModel {
                        Name  = "Arthur C. Clarke",
                        Items = new List <MenusModel> {
                            new MenusModel {
                                Name = "2010, Una odisea espacial"
                            },
                            new MenusModel {
                                Name = "2010: Odisea dos"
                            },
                            new MenusModel {
                                Name = "2061: Odisea tres"
                            },
                            new MenusModel {
                                Name = "3001: Odisea final"
                            },
                            new MenusModel {
                                Name = "Cita con Rama"
                            },
                            new MenusModel {
                                Name = "Rama II"
                            },
                            new MenusModel {
                                Name = "El jardín de Rama"
                            },
                            new MenusModel {
                                Name = "Rama revelada"
                            },
                            new MenusModel {
                                Name = "Las arenas de Marte"
                            },
                            new MenusModel {
                                Name = "El fin de la infancia"
                            }
                        }
                    }
                }
            };


            return(await Task.FromResult(View(model)));
        }