예제 #1
0
        public async Task <ActionResult> Delete(Guid id)
        {
            var user = await _userRepository.GetById(AuthUserId);

            if (user == null)
            {
                return(Unauthorized());
            }

            var element = await _elementRepository.GetById(id);

            if (element == null)
            {
                return(NotFound());
            }

            var toDoList = await _listRepository.GetById(element.ToDoListId);

            if (toDoList == null)
            {
                return(BadRequest());
            }

            await _elementRepository.Remove(element);

            return(NoContent());
        }
예제 #2
0
        /// <summary>
        /// Removes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns><c>true</c> if success, <c>false</c> otherwise.</returns>
        public bool Remove(Element element)
        {
            if (element == null)
            {
                return(false);
            }

            try
            {
                using (var repository = _repositoryFactory.GetRepositoryInstance())
                {
                    var currentItem = GetLocalization(element.Name, element.Category, element.Culture, repository);
                    if (currentItem == null)
                    {
                        return(false);
                    }

                    repository.Remove(currentItem);
                    repository.UnitOfWork.Commit();
                }
                return(_cacheRepository.Remove(element));
            }
            catch
            {
                return(false);
            }
        }
예제 #3
0
        public bool Remove(Element element)
        {
            var r = inner.Remove(element);

            if (r)
            {
                RemoveCache(element);
            }
            return(r);
        }
        public async Task <IActionResult> OnPostRemoveAsync(Guid id)
        {
            if (ModelState.IsValid)
            {
                await _elementRepository.Remove(id);

                return(RedirectToPage());
            }
            return(Page());
        }
        /// <summary>
        /// Removes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns><c>true</c> if success, <c>false</c> otherwise.</returns>
        public bool Remove(Element element)
        {
            var r = _innerRepository.Remove(element);

            if (r)
            {
                RemoveCache(element);
            }
            return(r);
        }