コード例 #1
0
 public ActionResult <bool> DeletePhoto(DeletePhotoModel photoModel)
 {
     try
     {
         _repository.DeletePhoto(new Photo {
             PhotoNum = photoModel.PhotoNum, User = LoggedUser
         });
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #2
0
        public async Task <IActionResult> Delete([FromBody] DeletePhotoModel model)
        {
            if (!model.Id.HasValue)
            {
                return(BadRequestJsonResult(JsonResponse.ErrorResponse("Photo id not specified!")));
            }

            try
            {
                await _photoService.DeleteAsync(model.Id.Value);

                return(OkJsonResult(JsonResponse.SuccessResponse("Photo was delete with success!")));
            }
            catch (Exception exception)
            {
                _appLogger.LogError(exception);
                return(BadRequest(JsonResponse.ErrorResponse(exception)));
            }
        }