예제 #1
0
        public async Task <object> AddUpdateMenu(MenuViewModel menuViewModel, string UserName)
        {
            MyMenu.Shared.Models.Menu menu = new MyMenu.Shared.Models.Menu();
            menu.Name        = menuViewModel.Name;
            menu.Description = menuViewModel.Description;
            menu.ImgUrl      = menuViewModel.ImgUrl;
            menu.CompanyId   = menuViewModel.CompanyId;
            menu.CreatedBy   = UserName;
            menu.CreatedAt   = DateTime.Now;
            menu.UpdatedBy   = UserName;
            menu.UpdatedAt   = DateTime.Now;
            menu.IsActive    = true;
            menu.IsDelete    = false;
            context.Menu.Add(menu);
            await context.SaveChangesAsync();

            return(menu);


            //var menu = await context.Menu.FindAsync(menuViewModel.Id);
            //menu.Name = menuViewModel.Name;
            //menu.Description = menuViewModel.Description;
            //menu.UpdatedAt = DateTime.Now;
            //menu.UpdatedBy = UserName;
            //menu.IsActive = menuViewModel.IsActive;
            //context.Menu.Update(menu);
            //await context.SaveChangesAsync();
            //return menu;
        }
예제 #2
0
        public async Task <Shared.Models.Menu> AddMenu(MenuViewModel newmenu)
        {
            MyMenu.Shared.Models.Menu menu = new MyMenu.Shared.Models.Menu();
            menu.Name        = newmenu.Name;
            menu.Description = newmenu.Description;
            menu.ImgUrl      = newmenu.ImgUrl;
            menu.CompanyId   = newmenu.CompanyId;
            menu.CreatedAt   = DateTime.Now;
            menu.UpdatedAt   = DateTime.Now;
            menu.IsActive    = newmenu.IsActive;
            menu.IsDelete    = false;
            await context.Menu.AddAsync(menu);

            await context.SaveChangesAsync();

            return(menu);
        }