Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteModel(int id)
        {
            var model = await _modelService.GetModellByIdAsync(id);

            if (model == null)
            {
                return(BadRequest("Model not found"));
            }

            await _modelService.DeleteModelAsync(model);

            return(Ok(new
            {
                status = 200,
                message = "Model deleted successfully!"
            }));
        }
        public async Task <IActionResult> DeleteAsync(Guid?id)
        {
            try
            {
                if (id == null)
                {
                    return(BadRequest());
                }

                await _service.DeleteModelAsync(id);
            }
            catch
            {
                return(StatusCode(500));
            }
            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Delete(int accountId, int id)
        {
            try
            {
                Guard.AgainstAccountNumberMismatch(GetAccountIdClaim(), accountId.ToString(), "userClaim.accountId", "accountId");
                await _modelService.DeleteModelAsync(accountId, id);

                return(Ok());
            }
            catch (ArgumentNullException)
            {
                return(NotFound($"Error finding model {id} to delete"));
            }
            catch (AccountConflictException)
            {
                return(Forbid());
            }
            catch (Exception)
            {
                return(Conflict($"Error deleting model {id}"));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete(Guid id)
        {
            await _modelService.DeleteModelAsync(id);

            return(Ok());
        }