Ejemplo n.º 1
0
        public HttpResponseMessage Delete(int id)
        {
            if (id <= 0)
            {
                return(GetBadFileDeleteRequest());
            }

            /* Checks to see if the file on the server is actually deleted before deleting it from the database. */
            bool isDeleted = _fileServices.deleteFilesInDirectory(id);

            if (isDeleted == true)
            {
                _imagesService.DeleteFromProductImages(id);
                _imagesService.Delete(id);

                return(Request.CreateResponse(HttpStatusCode.OK, id));
            }
            else
            {
                ErrorResponse err = new ErrorResponse("The file is not deleted.");
                return(Request.CreateResponse(HttpStatusCode.BadRequest, err));
            }
        }