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()); }
/// <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); } }
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); }