Exemplo n.º 1
0
        public IActionResult NewItem(Item item)
        {
            string userId = User.Claims.SingleOrDefault(c => c.Type == "UserID").Value;
            var    result = _itemService.AddNewItem(item, userId);

            return(Ok(result));
        }
Exemplo n.º 2
0
        public void AddNewItemFromViewModel(ItemViewModel vm)
        {
            var itemId = _itemServ.AddNewItem(new Item {
                Name = vm.Name, Cost = vm.Cost
            });

            _itemServ.UpdateItemIngredientsForItemId(itemId, CreateItemIngredientsFromSelectList(itemId, vm.IngredientsSelected).ToList());
        }
        public void GivenANewItem_Happy_WhenAddingAnItem_TheItemIsAddedToTheDB()
        {
            var totalCountOfItemsInDB = ItemDatabase.ItemDB.Count;
            var newItem = new Item("test", 12m, 5, "somerandomdescriptionhereplss");

            itemService.AddNewItem(newItem);
            var newCountOfItemsInDB = ItemDatabase.ItemDB.Count;

            Assert.True(totalCountOfItemsInDB + 1 == newCountOfItemsInDB);
        }
Exemplo n.º 4
0
 public ActionResult AddNewItem([FromBody] NewItemDTO givenItem)
 {
     try
     {
         _itemService.AddNewItem(_itemMapper.DTOToItem(givenItem));
         return(Ok());
     }
     catch (ItemException ItemEx)
     { return(BadRequest(ItemEx.Message)); }
     catch (Exception ex)
     { return(BadRequest(ex.Message)); }
 }
Exemplo n.º 5
0
        public Task <AlpApiResponse> AddNewItem([FromBody] ItemDto item)
        {
            var sessionToken = HttpContext.Request.Headers["sessiontoken"];

            if (!_accountService.Authorize(sessionToken, new List <RoleType> {
                RoleType.Admin
            }))
            {
                return(Task.FromResult(new AlpApiResponse {
                    Success = false, Message = "Nincs jogosultsága ehhez a művelethez!"
                }));
            }
            return(_itemService.AddNewItem(item));
        }