Beispiel #1
0
        public ActionResult Delete(int id)
        {
            var apiResult = TryExecute(() =>
            {
                _hobbyRepository.Delete(id);
                _unitOfWork.Commit();
                return(true);
            }, "Hobby deleted sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> DeleteHobby(int hobbyId)
        {
            try
            {
                var hobby = await _hobbyRepository.GetHobby(hobbyId);

                if (hobby == null)
                {
                    return(NotFound($"Could not find any hobby with that id: {hobbyId}"));
                }

                _hobbyRepository.Delete(hobby);
                if (await _hobbyRepository.Save())
                {
                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }
            return(BadRequest());
        }
 public void Delete(int id)
 {
     _repository.Delete(id);
 }
Beispiel #4
0
        public IActionResult Delete([FromBody] int id)
        {
            _repository.Delete(id);

            return(Ok());
        }