コード例 #1
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var selectedValue = await _valueService.GetByIdAsync(id);

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

                var valueToDeleted = new ValueForDeleteDto
                {
                    Id   = selectedValue.Id,
                    Name = selectedValue.Name
                };

                var deletedValue = _valueService.Delete(valueToDeleted);
                return(NoContent());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500));
            }
        }
コード例 #2
0
        public bool Delete(ValueForDeleteDto valueForDeleteDto)
        {
            var valueToDelete = new Value
            {
                Id   = valueForDeleteDto.Id,
                Name = valueForDeleteDto.Name
            };

            var deletedValue = _uow.Values.Delete(valueToDelete);

            return(_uow.Save() > 0 ? true : false);
        }