示例#1
0
        public IActionResult Delete(int id)
        {
            try
            {
                MyModel singleById = _exampleRepository.GetSingle(id);

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

                _exampleRepository.Delete(singleById);
                int save = _exampleRepository.Save();

                if (save > 0)
                {
                    return(NoContent());
                }

                return(BadRequest());
            }
            catch (Exception exception)
            {
                //Do something with the exception
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
示例#2
0
 public bool DeleteExampleModel(int id)
 {
     try
     {
         _repository.Delete(id);
         _repository.SaveChanges();
     }
     catch
     {
         return(false);
     }
     return(true);
 }
        public int Delete(long Id)
        {
            _logger.LogDebug("Delete");
            var entityToDelete = Get(Id);

            if (entityToDelete == null)
            {
                _logger.LogWarning("Invalid ID");
                return(0);
            }

            var result = _repository.Delete(Id);

            _logger.LogDebug($"Delete: entity with id({Id}) deleted");

            return(result);
        }
示例#4
0
 public async Task <bool> Delete(long id)
 {
     return(await _exampleRepository.Delete(id));
 }
示例#5
0
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="id">The id of a record.</param>
        /// <returns>True if the record was deleted, false otherwise.</returns>
        public bool Delete(string id)
        {
            var myData = repository.Delete(id);

            return(myData);
        }