public Result SavePicture(HttpPostedFileBase httpPostedFile, int usesrId) { if (!_allowedExtentions.Any(httpPostedFile.FileName.Contains)) { return new Result { Message = "Only picture allowed.", Status = "Error" } } ; var name = _fileSystemPathService.GenerateUniqueFileName(httpPostedFile.FileName); var path = _fileSystemPathService.GetImageSavePath() + name; var uploudfile = new UploadFile { Name = name, UserId = usesrId }; var photo = _uploadFileRepository.SaveFile(uploudfile); try { httpPostedFile.SaveAs(path); } catch (Exception e) { _uploadFileRepository.DeleteFile(photo.Id); return(new Result { Message = "Error: ." + e.Message, Status = "Error" }); } return(new Result { Message = "Saved.", Status = "Success", Photo = photo }); }
public async Task <PersonalModel> DeleteAsync(int id) { var model = await _repository.GetById(id); await _repository.DeleteAsync(id); _upload.DeleteFile(model.ProfileImage); return(model); }
public async Task <DocumentModel> DeleteAsync(int id) { var model = await _repository.GetById(id); await _repository.DeleteAsync(id); _upload.DeleteFile(model.path); return(model); }