예제 #1
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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();
        }
예제 #5
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));
            }
        }