public IActionResult Delete(int id)
        {
            var context = HttpContext.User.Identity;
            var userId  = int.Parse(context.Name);

            _garageService.Delete(userId, id);
            return(Ok());
        }
Example #2
0
        public async Task <IActionResult> Delete(int garageId)
        {
            try
            {
                var result = await _garageService.Delete(garageId);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
                return(BadRequest());
            }
        }
        public IHttpActionResult DeleteGarage(int GarageId)
        {
            ResponseDataDTO <int> response = new ResponseDataDTO <int>();

            try
            {
                var GarageDeleted = _Garageservice.Find(GarageId);
                if (GarageDeleted != null)
                {
                    _Garageservice.Delete(GarageDeleted);

                    // return response
                    response.Code    = HttpCode.OK;
                    response.Message = MessageResponse.SUCCESS;
                    response.Data    = 1;
                    return(Ok(response));
                }
                else
                {
                    // return response
                    response.Code    = HttpCode.NOT_FOUND;
                    response.Message = MessageResponse.FAIL;
                    response.Data    = 0;

                    return(Ok(response));
                }
            }
            catch (Exception ex)
            {
                response.Code    = HttpCode.INTERNAL_SERVER_ERROR;
                response.Message = MessageResponse.FAIL;
                response.Data    = 0;
                Console.WriteLine(ex.ToString());

                return(Ok(response));
            }
        }