Exemplo n.º 1
0
        public async Task <IActionResult> UpdateOrCreateList([FromRoute] int id, [FromBody] ItemList list)
        {
            Validator.Assert(list != null && list.Id == id && list.Id != 0, ValidationAreas.InputParameters);

            var exists = await _listsRepository.Exists(id);

            if (exists)
            {
                await _listsRepository.Update(id, list);
            }
            else
            {
                await _listsRepository.Create(list);
            }

            return(Ok(list));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddItemToList([FromRoute] int listId, [FromRoute] int itemId)
        {
            var listExists = await _listsRepository.Exists(listId);

            var itemExists = await _itemsRepository.Exists(itemId);

            Validator.Assert(listExists, ValidationAreas.NotExists);
            Validator.Assert(itemExists, ValidationAreas.NotExists);

            await _itemsListRelationsRepository.Create(new ItemsListRelation()
            {
                ListId   = listId,
                ItemId   = itemId,
                IsActive = true
            });

            return(Ok());
        }
Exemplo n.º 3
0
 public bool Exists(string name, int userId)
 {
     return(_listsRepository.Exists(name.Trim(), userId));
 }