public IHttpActionResult Delete(Guid tripId, Guid pictureId) { try { using (var uow = new DeletePicture(null, tripId, pictureId)) { var uowResult = uow.Execute(); switch (uowResult.Status) { case UnitOfWork.UnitOfWorkStatus.Ok: return(StatusCode(HttpStatusCode.NoContent)); case UnitOfWork.UnitOfWorkStatus.Invalid: return(BadRequest()); case UnitOfWork.UnitOfWorkStatus.NotFound: return(NotFound()); case UnitOfWork.UnitOfWorkStatus.Forbidden: return(StatusCode(HttpStatusCode.Forbidden)); default: return(InternalServerError()); } } } catch (Exception) { return(InternalServerError()); } }
public IHttpActionResult Delete(Guid tripId, Guid pictureId) { try { // the user can delete. But can he also delete THIS picture? string ownerId = TokenIdentityHelper.GetOwnerIdFromToken(); using (var uow = new DeletePicture(ownerId, tripId, pictureId)) { var uowResult = uow.Execute(); switch (uowResult.Status) { case UnitOfWork.UnitOfWorkStatus.Ok: return(StatusCode(HttpStatusCode.NoContent)); case UnitOfWork.UnitOfWorkStatus.Invalid: return(BadRequest()); case UnitOfWork.UnitOfWorkStatus.NotFound: return(NotFound()); case UnitOfWork.UnitOfWorkStatus.Forbidden: return(StatusCode(HttpStatusCode.Forbidden)); default: return(InternalServerError()); } } } catch (Exception) { return(InternalServerError()); } }