public AdsServiceTest() { IConfiguration configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); _pictureRepository = new PicturesRepository(new InMemoryPersistence <PictureVO>()); _adRepository = new AdsRepository(new InMemoryPersistence <AdVO>()); _calculator = new RuleCalculator(_pictureRepository); _service = new AdsService(_adRepository, _pictureRepository, _calculator, configuration); }
public PicturesViewModel(string filePath, Picture picture = null) { DataStore = new PicturesRepository(filePath); IsNewPicture = picture == null; Picture = picture ?? new Picture(); Pictures = new ObservableCollection <Picture>(); AddItemCommand = new Command <Picture>(async(pic) => await ExecuteAddPictureCommand(pic).ConfigureAwait(false)); LoadItemCommand = new Command(async() => await ExecuteLoadPicturesCommand().ConfigureAwait(false)); }
public async Task LoadPicturesAsync() { // TODO: yield iterator var pictures = await PicturesRepository.GetPictures(); Pictures.Clear(); foreach (var picture in pictures) { Pictures.Add(picture); } }
public IActionResult Post() { var files = Request.Form.Files; long size = files.Sum(f => f.Length); //size > 100MB refuse upload ! if (size > 104857600) { return(Json(PicturesRepository.Error_Msg_Ecode_Elevel_HttpCode("pictures total size > 100MB , server refused !"))); } List <string> filePathResultList = new List <string>(); foreach (var file in files) { var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); string filePath = hostingEnv.WebRootPath + $@"\Files\Pictures\"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string suffix = fileName.Split('.')[1]; if (!pictureFormatArray.Contains(suffix)) { return(Json(PicturesRepository.Error_Msg_Ecode_Elevel_HttpCode("the picture format not support ! you must upload files that suffix like 'png','jpg','jpeg','bmp','gif','ico'."))); } fileName = Guid.NewGuid() + "." + suffix; string fileFullName = filePath + fileName; using (FileStream fs = System.IO.File.Create(fileFullName)) { file.CopyTo(fs); fs.Flush(); } filePathResultList.Add($"/src/Sino.OnlineMarket.Webhost/wwwroot/FilesPictures/{fileName}"); } string message = $"{files.Count} file(s) /{size} bytes uploaded successfully!"; return(Json(PicturesRepository.Success_Msg_Data_DCount_HttpCode(message, filePathResultList, filePathResultList.Count))); }
public GalleryViewModel(string filePath) { PicturesDataStore = new PicturesRepository(filePath); AlbumsDataStore = new AlbumRepository(filePath); TagsDataStore = new TagRepository(filePath); Pictures = new ObservableCollection <Picture>(); Albums = new ObservableCollection <Album>(); Tags = new ObservableCollection <Tag>(); LoadPicturesCommand = new Command(async() => await ExectueLoadPicturesCommand().ConfigureAwait(false)); LoadAlbumsCommand = new Command(async() => await ExectueLoadAlbumsCommand().ConfigureAwait(false)); LoadTagsCommand = new Command(async() => await ExectueLoadTagsCommand().ConfigureAwait(false)); LoadAlbumPicturesCommand = new Command <int>(async(albumId) => await ExecuteLoadAlbumPicturesCommand(albumId).ConfigureAwait(false)); LoadTaggedPicturesCommand = new Command <int>(async(tagId) => await ExecuteLoadTaggedPicturesCommand(tagId).ConfigureAwait(false)); SearchItemComand = new Command <string>(async(searchTerm) => await ExecuteSearchPicturesCommand(searchTerm).ConfigureAwait(false)); DeletePictureCommand = new Command <int>(async(pictureId) => await ExecuteDeletePictureCommand(pictureId).ConfigureAwait(false)); }
private async void PopulatePictureCollection() { List <PictureSliderModel> list = new List <PictureSliderModel>(); PicturesRepository picRep = new PicturesRepository(App.FilePath); if (this.PicturesArray != null) { foreach (var byteArray in this.PicturesArray) { var pic = await picRep.FindItemAsync(byteArray.Key).ConfigureAwait(false); var tags = await picRep.FindTagByPictureIdAsync(byteArray.Key).ConfigureAwait(false); list.Add(new PictureSliderModel() { Title = pic.Notes, Tags = string.Join(" - ", tags.Select(c => c.Name)), Color = "White", ImageData = ImageSource.FromStream(() => new MemoryStream(byteArray.Value)) }); } } else { var pic = await picRep.FindItemAsync(PictureId).ConfigureAwait(false); var tags = await picRep.FindTagByPictureIdAsync(PictureId).ConfigureAwait(false); list.Add(new PictureSliderModel() { Title = pic.Notes, Tags = string.Join(" - ", tags.Select(c => c.Name)), Color = "White", ImageData = PictureSource.Source }); } PictureNode = new ObservableCollection <PictureSliderModel>(list); }
public static void Init() { noTest = 0; hasBeenTested = true; List <Picture> lstPictures = new PicturesRepository().Pictures().ToList(); pictures = new List <Picture>(); while (pictures.Count < NB_TESTS && lstPictures.Count > 0) { Picture chosenPicture = lstPictures[new Random().Next(0, lstPictures.Count())]; pictures.Add(chosenPicture); lstPictures.Remove(chosenPicture); } score = new Score { TestDate = DateTime.Now, Category = Category.Animal, AmountOfRightAnswers = 0, AmountOfQuestions = NB_TESTS }; }
public async void OnPictureCaptured(object sender, PictureCapturedEventArgs e) => await PicturesRepository.SaveNewCaptureAsync(e.Stream);
public PictureService(PicturesRepository picturesRepository) { _pictureRepository = picturesRepository; }
public ServicePicture(Progress <double> progress, PicturesRepository picturesRepository) { _progress = progress; _picturesRepository = picturesRepository; }
public PictureRepository(IPictureDataAccess pictureDataAccess, PicturesRepository pictureRepository, CampaignsRepository campaignsRepository) { _pictureDataAccess = pictureDataAccess; _pictureRepository = pictureRepository; _campaignsRepository = campaignsRepository; }
public void Dispose() { _adRepository = null; _pictureRepository = null; _service = null; }
public void Dispose() { _pictureRepository = null; _adRepository = null; }
public DataLayerTest() { _pictureRepository = new PicturesRepository(new InMemoryPersistence <PictureVO>()); _adRepository = new AdsRepository(new InMemoryPersistence <AdVO>()); }