示例#1
0
        public async Task <IResult> DeleteAsync(Example example)
        {
            var deleted = await _exampleRepository.GetAsync(i => i.Id == example.Id);

            if (deleted != null)
            {
                await _exampleRepository.DeleteAsync(deleted);

                return(new SuccessResult($"{example} Id'sine sahip Örnek Veri Başarıyla Silinmiştir."));
            }

            else
            {
                return(new ErrorResult($"{example.Id} Id'sine sahip Örnek Veri Bulunamadığı için silme işlemi başarısız oldu."));
            }
        }
示例#2
0
        public async Task <ActionResult> Delete(Guid id)
        {
            try
            {
                var exampleToRemove = await exampleRepository.GetAsync(id);

                if (exampleToRemove != null)
                {
                    await exampleRepository.DeleteAsync(exampleToRemove);
                }
                return(Ok());
            }
            catch (Exception exception)
            {
                logger.LogError(exception, "Failed to delete Example");
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve examples"));
            }
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CommonExample = await _repository.GetExampleByIdAsync(id);

            if (CommonExample != null)
            {
                await _repository.DeleteAsync(CommonExample.Id);

                await _repository.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }