public ActionResult DeleteImage(string fileName, string subjectTitle) { var image = _imagesService.GetByFileName(fileName); _imagesService.Delete(image.Id); return(Redirect(String.Format("/Subjects/Subject?title={}", subjectTitle))); }
public HttpResponseMessage Delete(int Id) { SuccessResponse response = new SuccessResponse(); _imagesService.Delete(Id); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public IActionResult Delete([FromForm(Name = ("Id"))] int Id) { var carImage = _imagesService.Get(Id).Data; var result = _imagesService.Delete(carImage); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public void Save(AddEditProjectInputModel input) { var dbModel = Mapper.Map <Project>(input); if (input.FileUploaded != null) { // Delete the old image if (dbModel.ImageId != null) { imageServices.Delete(dbModel.ImageId.Value); } dbModel.ImageId = imageServices.Save(input.FileUploaded); } this.Data.Projects.Update(dbModel); this.Data.SaveChanges(); }
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)); } }