public MenuDTO AddNewMenu(PostMenuDTO menuDTO, string userId) { var newMenu = _menuFactory.Create(menuDTO); newMenu.UserId = userId; _uow.Menus.Add(newMenu); _uow.SaveChanges(); return(_menuFactory.Create(newMenu)); }
public IActionResult Create([FromBody] Models.Menu menu) { IActionResult result = null; if (menu == null) { result = BadRequest("Missing menu data"); } if (result == null) { using (ILifetimeScope scope = m_container.BeginLifetimeScope()) { IMenuFactory factory = scope.Resolve <IMenuFactory>(); IMenu innerMenu = factory.Create(); IMapper mapper = new Mapper(m_mapperConfiguration); mapper.Map <Models.Menu, IMenu>(menu, innerMenu); if (string.IsNullOrEmpty(innerMenu.Title)) { result = BadRequest("Missing title"); } if (result == null) { IMenuSaver saver = scope.Resolve <IMenuSaver>(); saver.Create(m_settings.Value, innerMenu); result = Ok(mapper.Map <Models.Menu>(innerMenu)); } } } return(result); }
public void Execute(CreateMenuModel model) { var date = _dateService.GetDate(); var menuModel = new MenusListItemModel(); menuModel.Id = Guid.NewGuid(); menuModel.Name = model.Name; menuModel.Icon = model.Icon; menuModel.Url = model.Url; menuModel.Created = date; menuModel.Modified = date; menuModel.MenuType = model.MenuType; menuModel.NoOrder = model.NoOrder; var menu = _factory.Create(menuModel); _database.Menus.Add(menu); _database.Save(); }
protected override IEnumerable <UIElement> GetItems(object context) => _menuFactory.Create(_contextMenu, context);