public Models.MenuItem MenuItemEntityToModel(Entities.MenuItem menuItem)
 => new MapperConfiguration(cfg => cfg.CreateMap <Entities.MenuItem,
                                                  Models.MenuItem>()
                            .ForMember(dest => dest.Price, opt => opt.MapFrom(src =>
                                                                              src.Price.ToString())))
 .CreateMapper()
 .Map <Models.MenuItem>(menuItem);
        public void MapMenuItemModelToEntity(Models.MenuItem menuItemMod,
                                             Entities.MenuItem menuItemEnt)
        {
            var mapper = new MapperConfiguration(configure =>
                                                 configure.CreateMap <Models.MenuItem, Entities.MenuItem>()
                                                 .ForMember(dest => dest.Category, opt => opt.Ignore()))
                         //.ForMember(dest => dest.Price, opt => opt.MapFrom(src =>
                         //decimal.Parse(src.Price))))
                         .CreateMapper();

            mapper.Map(menuItemMod, menuItemEnt);
        }
Exemple #3
0
        private async void btnActualizar_Click(object sender, RoutedEventArgs e)
        {
            CategoriaMenu selectedCategoria = this.categoriaCB.SelectedItem as CategoriaMenu;
            string        nombre;
            string        descripcion;

            nombre      = txtNombre.Text;
            descripcion = txtDescripcion.Text;
            int valor = Int32.Parse(txtValor.Text);


            MenuItemDAO dao = new MenuItemDAO();

            //var listadoMenu = await dao.GetAll();
            //var result = (from u in listadoMenu
            //              where u.item_nombre == nombre
            //              select new
            //              {
            //                  u.cat_menu_id
            //              }).FirstOrDefault();

            //if (result != null)
            //{

            //    MessageBox.Show("Menú ya Existe");
            //    this.Close();

            //}

            //else
            try
            {
                Entities.MenuItem obj = new Entities.MenuItem()
                {
                    item_id     = this.item_id,
                    cat_menu_id = selectedCategoria.cat_menu_id,
                    item_nombre = nombre,
                    item_desc   = descripcion,
                    item_val    = valor
                };
                var response = await dao.Update(obj);

                MessageBox.Show("Item Menú Actualizado Exitosamente", "Result", MessageBoxButton.OK, MessageBoxImage.Information);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Item Menú no Actualizado");
            }
        }
Exemple #4
0
        private async void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            CategoriaMenu selectedCategoria = this.categoriaCB.SelectedItem as CategoriaMenu;
            string        nombre;
            string        descripcion;
            int           valor;

            nombre      = txtNombre.Text;
            descripcion = txtDescripcion.Text;
            valor       = Int32.Parse(txtValor.Text);

            MenuItemDAO dao         = new MenuItemDAO();
            var         listadoMenu = await dao.GetAll();

            var result = (from u in listadoMenu
                          where u.item_nombre == nombre
                          select new
            {
                u.cat_menu_id
            }).FirstOrDefault();

            if (result != null)
            {
                MessageBox.Show("Menú ya Existe");
                this.Close();
            }

            else
            {
                try
                {
                    Entities.MenuItem obj = new Entities.MenuItem()
                    {
                        cat_menu_id = selectedCategoria.cat_menu_id,
                        item_nombre = nombre,
                        item_desc   = descripcion,
                        item_val    = valor
                    };
                    var response = await dao.Save(obj);

                    MessageBox.Show("Item Menú Añadido Exitosamente", "Result", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Item Menú no Añadido, Podría Existir Duplicidad de ID");
                }
            }
        }
Exemple #5
0
        public static Entities.MenuItem CreateMenuItem(Entities.Menu menu, bool subItem, Entities.MenuItem parentMenuItem)
        {
            var menuItemNew = new Entities.MenuItem(menu);
            menuItemNew.ItemText = RandomString(8, true);
            menuItemNew.Page = new Entities.Page();
            menuItemNew.Menu = menu;
            menuItemNew.ParentMenuItem = parentMenuItem;
            menu.MenuItems.Add(menuItemNew);

            if(subItem)
            {
                for (int i = 0; i < 3; i++)
                    menuItemNew.SubItems.Add(CreateMenuItem(menu, false, menuItemNew));
            }

            return menuItemNew;
        }
Exemple #6
0
        public static void CreateMenu()
        {
            var userBiz = container.Resolve<Business.IUser>();

            var menuBiz = container.Resolve<Business.IMenu>();

            //Menu
            Entities.Menu menu = new Entities.Menu() { Name = "default" };

            //Entities.Menu menu = menuBiz.Query(m => m.Id == 1, "MenuItems").FirstOrDefault();

            //SubItems
            Entities.MenuItem homeItem = new Entities.MenuItem(menu);
            homeItem.ItemText = "HOME";
            homeItem.Menu = menu;
            homeItem.Page = new Entities.Page() { Name = "Default", Link = "Default.aspx" };

            Entities.MenuItem whoItem = new Entities.MenuItem(menu);
            whoItem.ItemText = "O MORDOMO";
            whoItem.Menu = menu;
            whoItem.Page = new Entities.Page() { Name = "Quem Somos", Link = "Who.aspx" };

            Entities.MenuItem servItem = new Entities.MenuItem(menu);
            servItem.ItemText = "SERVIÇOS";
            servItem.Menu = menu;
            servItem.Page = new Entities.Page() { Name = "Serviços", Link = "Services.aspx" };

            Entities.MenuItem parcItem = new Entities.MenuItem(menu);
            parcItem.ItemText = "PARCEIROS";
            parcItem.Menu = menu;
            parcItem.Page = new Entities.Page() { Name = "Parceiros", Link = "Partners.aspx" };

            Entities.MenuItem contItem = new Entities.MenuItem(menu);
            contItem.ItemText = "CONTATO";
            contItem.Menu = menu;
            contItem.Page = new Entities.Page() { Name = "Contato", Link = "Contact.aspx" };

            menu.MenuItems.Add(homeItem);
            menu.MenuItems.Add(whoItem);
            menu.MenuItems.Add(servItem);
            menu.MenuItems.Add(parcItem);
            menu.MenuItems.Add(contItem);

            menuBiz.Save(menu, true);
        }