public IActionResult CreateFor(ExperienceCreateForExistingProductViewModel experienceCreateVM) { if (ModelState.IsValid) { string uniqueFileName = PhotoHelper.SaveImageAndReturnUniqueFileName(experienceCreateVM.Photo, _hostingEnvironment, "images/products"); var product = _productRepository.GetProduct(int.Parse(TempData["ProductID"].ToString())); var experience = new Experience { ProductID = product.ProductID, Evaluation = experienceCreateVM.Evaluation, Describe = experienceCreateVM.Describe, Recommendation = experienceCreateVM.Recommendation, UserName = User.FindFirst(ClaimTypes.Name).Value, PhotoPath = uniqueFileName, Date = DateTime.Now }; var addedExperience = _experienceRepository.AddExperience(experience); return(RedirectToAction("details", new { experienceID = addedExperience.ExperienceID })); } return(View()); }
private async void TakePhotoButton_Click(object sender, RoutedEventArgs e) { BitmapImage bitmapSource = await PhotoHelper.GetPhotoFromCameraLaunch(); if (bitmapSource == null) { return; } // Specify a random location // var currentLocation = await LocationHelper.GetRandomGeoposition(); //Geopoint geopoint = new Geopoint(currentLocation); var currentLocation = await LocationHelper.GetCurrentLocationAsync(); LocationData location = new LocationData { Position = currentLocation.Geopoint.Position, ImageSource = bitmapSource }; this.Locations.Add(location); this.LocationsView.UpdateLayout(); LocationsView.SelectedItem = location; await LocationHelper.TryUpdateMissingLocationInfoAsync(location, null); }
private async void OnChangePictureButton(object sender, EventArgs e) { var imagePath = await PhotoHelper.TakePhotoPathAsync(screen); if (imagePath == null) { return; } new ImageCropper() { PageTitle = "Profile Picture", AspectRatioX = 1, AspectRatioY = 1, CropShape = ImageCropper.CropShapeType.Oval, Success = (imageFile) => { Device.BeginInvokeOnMainThread(() => { ProfilePicture.Source = ImageSource.FromFile(imageFile); GetImageString(imageFile); }); } }.Show(this, imagePath); }
public async Task <ImageFileModelResult> PickPhoto() { bool hasPermission = await _permissionService.CheckPermissions(new List <Permission>() { Permission.Camera, Permission.Storage }); if (!hasPermission) { return(null); } MediaFile file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { CompressionQuality = 100, SaveMetaData = true, CustomPhotoSize = 100, PhotoSize = PhotoSize.MaxWidthHeight }); if (file == null) { return(null); } byte[] localArray = PhotoHelper.ConvertToByteArray(file.GetStream()); return(new ImageFileModelResult() { FilePath = file.Path, ImageArray = localArray }); }
private void AddPhoto(Product product, PhotoHelper photo1, PhotoHelper photo2, PhotoHelper photo3) { if (photo1.ImageName != null) { product.ImageName1 = photo1.ImageName; product.PhotoFile1 = photo1.PhotoFile; product.ImageMimeType1 = photo1.ImageMimeType; } if (photo2.ImageName != null) { product.ImageName2 = photo2.ImageName; product.PhotoFile2 = photo2.PhotoFile; product.ImageMimeType2 = photo2.ImageMimeType; } if (photo3.ImageName != null) { product.ImageName3 = photo3.ImageName; product.PhotoFile3 = photo3.PhotoFile; product.ImageMimeType3 = photo3.ImageMimeType; } if (photo1.ImageName == null && photo2.ImageName == null && photo3.ImageName == null) { product.ImageMimeType1 = "image/png"; product.ImageName1 = "no_image.png"; } }
public void List() { set("addLink", to(Add)); set("sortLink", to(OrderList)); List <PhotoAlbum> albumList = albumService.GetListByApp(ctx.app.Id); IBlock block = getBlock("list"); foreach (PhotoAlbum album in albumList) { block.Set("album.Name", album.Name); block.Set("album.Link", to(Edit, album.Id)); int dataCount = getDataCount(album); block.Set("album.DataCount", dataCount); block.Set("album.Updated", album.Created.ToShortDateString()); String desc = strUtil.HasText(album.Description) ? "<div class=\"descriptionInfo\">" + album.Description + "</div>" : ""; block.Set("album.Description", desc); String coverImg = PhotoHelper.getCover(album); block.Set("album.Cover", coverImg); block.Next(); } }
private async void RadioButton_Click(object sender, RoutedEventArgs e) { RadioButton radioButton = (RadioButton)sender; string imagePath = ""; switch (radioButton.Content.ToString()) { case "Arial": this.InputMap.Style = MapStyle.Aerial; MapOptionButton.Flyout.Hide(); break; case "Road": this.InputMap.Style = MapStyle.Road; MapOptionButton.Flyout.Hide(); break; case "Take Photo": imagePath = await PhotoHelper.GetPhotoFromCameraLaunch(true); if (imagePath != null) { Dictionary <string, string> LocationInfo = new Dictionary <string, string>(); LocationInfo.Add("ImagePath", imagePath); App.PageName = "Post to TripTrak"; this.Frame.Navigate(typeof(PostPhoto), LocationInfo); } radioButton.IsChecked = false; MainButton.Flyout.Hide(); break; case "Photo Libs": imagePath = await PhotoHelper.GetPhotoFromCameraLaunch(false); if (imagePath != null) { Dictionary <string, string> LocationInfo = new Dictionary <string, string>(); LocationInfo.Add("ImagePath", imagePath); App.PageName = "Post to TripTrak"; this.Frame.Navigate(typeof(PostPhoto), LocationInfo); } radioButton.IsChecked = false; MainButton.Flyout.Hide(); break; case "Maps": ViewOptionButton.Flyout.Hide(); break; case "Photos": ViewOptionButton.Flyout.Hide(); break; default: break; } }
public async Task <IActionResult> PutProduct(Guid id, ProductViewModel productViewModel) { if (id != productViewModel.Id) { NotifyErrors("O id do produto não pertence a esse produto."); return(CustomResponse(productViewModel)); } if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } await _productService.Update(_mapper.Map <Product>(productViewModel), id); if (!string.IsNullOrWhiteSpace(productViewModel.Photo)) { PhotoHelper.SavePhoto(productViewModel.Id, productViewModel.Photo); } else { PhotoHelper.DeletePhoto(productViewModel.Id); } return(CustomResponse(productViewModel)); }
public async Task <ImageFileModelResult> TakePhoto(bool saveToAlbum = true) { bool hasPermission = await _permissionService.CheckPermissions(new List <Permission>() { Permission.Camera, Permission.Storage }); if (!hasPermission) { return(null); } string fileName = $"{Guid.NewGuid().ToString()}.jpg"; MediaFile file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "Photos", AllowCropping = false, PhotoSize = PhotoSize.MaxWidthHeight, CompressionQuality = 100, SaveToAlbum = saveToAlbum, Name = fileName, }); if (file == null) { return(null); } byte[] localArray = PhotoHelper.ConvertToByteArray(file.GetStream()); return(new ImageFileModelResult() { FileName = fileName, FilePath = file.Path, ImageArray = localArray }); }
public async Task <IActionResult> Import_V1_0([FromForm] O2CCertificateImportDto o2CCertificateImportDto) { var path = o2CCertificateImportDto.File.FileName; await using (var fileStream = new FileStream(path, FileMode.Create)) { await o2CCertificateImportDto.File.CopyToAsync(fileStream); } var str = System.IO.File.ReadAllText(path); var certificationForListDto = JsonConvert.DeserializeObject <List <O2CCertificateForCreateDto> >(str); var listCertificates = new List <O2CCertificate>(); foreach (var item in certificationForListDto) { var createCertificate = MappingCertificate(item); listCertificates.Add(createCertificate); } // var list = _mapper.Map<List<O2CCertificate>>(certificationForListDto); // import photos PhotoHelper.LoadCertificates(listCertificates); var certifications = await _certificatesBaseRepository.AddRangeAsync(listCertificates, o2CCertificateImportDto.CleanData); var certificatesReturn = _mapper.Map <List <O2CCertificateForListDto> >(certifications); return(Ok(certificatesReturn)); }
//---start-------------------------------------------------------------------------------------CLICK EVENTS---// private async void OnTakePhotoButton(object sender, EventArgs e) { var imageFile = await PhotoHelper.TakePhotoPathAsync(screen); if (imageFile == null) { return; } new ImageCropper() { PageTitle = "Passport Picture", AspectRatioX = 1, AspectRatioY = 1, CropShape = ImageCropper.CropShapeType.Rectangle, Success = (result) => { Device.BeginInvokeOnMainThread(() => { passportPicture.Source = ImageSource.FromFile(result); takePhotoButton.Text = "RETAKE PHOTO"; proceedButton.IsVisible = true; AddBase64ImageToLocalDB(result); }); } }.Show(this, imageFile); }
public void TestInitializer() { serializer = new SerializerImp(); client = new RestClientImpl(); helper = new PhotoHelper(client, serializer); }
public IActionResult EditCategory(EditCategoryViewModel editCategoryVM) { if (ModelState.IsValid) { string uniqueFileName = PhotoHelper.SaveImageAndReturnUniqueFileName(editCategoryVM.Photo, _hostingEnvironment, "images/categories"); if (!string.IsNullOrEmpty(uniqueFileName) && System.IO.File.Exists("wwwroot/images/categories/" + editCategoryVM.ExistingPhotoPath)) { try { System.IO.File.Delete("wwwroot/images/categories/" + editCategoryVM.ExistingPhotoPath); } catch { } } var existingPhotoPath = editCategoryVM.ExistingPhotoPath; var photoPath = uniqueFileName ?? existingPhotoPath; var categoryChanges = new Category { CategoryID = editCategoryVM.CategoryID, CategoryName = editCategoryVM.CategoryName, CategoryPhotoPath = photoPath }; _categoryRepository.UpdateCategory(categoryChanges); return(RedirectToAction("ListCategories")); } return(View("ListCategories")); }
private void ProcessPhoto(GalliumContext ctx, Photo photo) { Console.WriteLine($"Beginning processing of photo {photo.Name}"); try { if (!photo.HasFacesChecked) { photo.HasFacesChecked = true; var faces = PhotoHelper.UploadToFaceApiAsync(photo.FullName).Result; foreach (var face in faces) { var faceEntity = new Models.FaceApi.DetectedFace { HumanVerified = false, FaceRectangle = face.FaceRectangle, Photo = photo, FaceId = face.FaceId }; PhotoHelper.ExtractFaceFromPhoto(photo, faceEntity); faceEntity.FaceFile = DirectoryHelper.GetFacePath(face.FaceId.ToString()); ctx.DetectedFaces.Add(faceEntity); } ctx.SaveChanges(); } } catch (System.IO.IOException e) { Thread.Sleep(500); } catch (Exception e) { Thread.Sleep(5000); } }
public void Createproduct(Product product) { PhotoHelper photo1 = new PhotoHelper(product.PhotoAvatar1, product.ImageName1, product.PhotoFile1, product.ImageMimeType1); PhotoHelper photo2 = new PhotoHelper(product.PhotoAvatar2, product.ImageName2, product.PhotoFile2, product.ImageMimeType2); PhotoHelper photo3 = new PhotoHelper(product.PhotoAvatar3, product.ImageName3, product.PhotoFile3, product.ImageMimeType3); List <PhotoHelper> photoLst = new List <PhotoHelper>(); photoLst.Add(photo1); photoLst.Add(photo2); photoLst.Add(photo3); foreach (var item in photoLst) { if (item.PhotoAvatar != null && item.PhotoAvatar.Length > 0) { item.ImageMimeType = item.PhotoAvatar.ContentType; item.ImageName = Path.GetFileName(item.PhotoAvatar.FileName); using (var memoryStream = new MemoryStream()) { item.PhotoAvatar.CopyTo(memoryStream); item.PhotoFile = memoryStream.ToArray(); } } } AddPhoto(product, photo1, photo2, photo3); _context.Add(product); _context.SaveChanges(); }
public JsonResult GetComentList(User user, long subID = 2050, int page = 1, int pageSize = 10) { if (user == null || user.UserID == 0) { user = new User() { UserID = 10000, UserName = string.Empty }; } int pageindex = page; var result = new RestClient(user.UserID).ExecuteGet <ReturnResult <CiWong.Resource.Preview.DataContracts.Resource.CwComent> >(WebApi.GetCommentList, new { subject_id = subID, type = 1, son_category = 0, is_select_reply = 1, page_size = pageSize, page = page }); if (result.Data.record_count > 0) { var data = new CwComent() { page_index = result.Data.page_index, page_size = result.Data.page_size, record_count = result.Data.record_count, msg = "success", record_list = result.Data.record_list.Select(t => new CwCommentDTO() { comment_id = t.comment_id, com_subject_id = t.com_subject_id, com_content = t.com_content, com_user_id = t.com_user_id, com_user_name = t.com_user_name, com_userphoto = PhotoHelper.GetUserPhoto(t.com_user_id, 50), comment_type = t.comment_type, comment_type_name = t.comment_type_name, son_category = t.son_category, comment_date = t.comment_date, com_status = (int)t.com_status, replys = t.replys.OrderByDescending(p => p.reply_date).Select(m => new CwReplyDTO() { comment_id = m.comment_id, reply_id = m.reply_id, reply_user_id = m.reply_user_id, reply_user_name = m.reply_user_name, reply_content = m.reply_content, parend_id = m.parend_id, reply_date = m.reply_date, reply_userphoto = PhotoHelper.GetUserPhoto(m.reply_user_id, 50) }) }).ToList() }; return(Json(new ReturnResult <CwComent>(data))); } return(Json(result)); }
/// <summary> /// Loads the saved location data on first navigation, and /// attaches a Geolocator.StatusChanged event handler. /// </summary> protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (App.PageName.Equals("Start Trip")) { bool getPins = await GetPinsForGivenDate(); if (this.ViewModel.CheckedLocations.Count > 0) { oldPin = this.ViewModel.CheckedLocations[0]; oldPin.IsSelected = true; selectedImage.Source = await PhotoHelper.getImageSource(this.ViewModel.CheckedLocations[0].Photo.ImageName); } else if (this.ViewModel.PinnedLocations.Count > 0) { oldPin = this.ViewModel.PinnedLocations[0]; } else { oldPin = new LocationPin { DateCreated = HistoryDatePicker.Date, }; } } else if (App.PageName.Equals("End Trip")) { tripItem = e.Parameter as Trip; NameTb.Text = tripItem.Name; shareTb.Text = tripItem.ShareWith; DescTb.Text = tripItem.Description; startDateTb.Text = "End Date"; startPointTb.Text = "End Point"; submitButton.Content = "End Trip"; bool getPins = await GetPinsForGivenDate(); if (this.ViewModel.CheckedLocations.Count > 0) { oldPin = this.ViewModel.CheckedLocations[this.ViewModel.CheckedLocations.Count - 1]; oldPin.IsSelected = true; selectedImage.Source = await PhotoHelper.getImageSource(this.ViewModel.CheckedLocations[this.ViewModel.CheckedLocations.Count - 1].Photo.ImageName); } else if (this.ViewModel.PinnedLocations.Count > 0) { oldPin = this.ViewModel.PinnedLocations[this.ViewModel.PinnedLocations.Count - 1]; } else { oldPin = new LocationPin { DateCreated = HistoryDatePicker.Date, }; } } if (e.NavigationMode == NavigationMode.New) { } }
public async void getImageSource() { var source = await PhotoHelper.getImageSource(PhotoNameTb.Text); if (source != null) { PhotoImg.Source = source; } }
public KanbanProfile() { CreateMap <ImageModelEntity, ImageFileModelResult>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)) .ForMember(dest => dest.TaskId, opt => opt.MapFrom(src => src.TaskId)) .ForMember(dest => dest.FileName, opt => opt.MapFrom(src => src.FileName)) .ForMember(dest => dest.FilePath, opt => opt.MapFrom(src => src.FilePath)) .ForMember(dest => dest.ImageArray, opt => opt.MapFrom(src => PhotoHelper.ConvertToByteArrayFromPath(src.FilePath))); CreateMap <ImageFileModelResult, ImageModelEntity>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)) .ForMember(dest => dest.TaskId, opt => opt.MapFrom(src => src.TaskId)) .ForMember(dest => dest.FileName, opt => opt.MapFrom(src => src.FileName)) .ForMember(dest => dest.FilePath, opt => opt.MapFrom(src => src.FilePath)); CreateMap <TaskModelEntity, TaskModelResult>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)) .ForMember(dest => dest.AssignedUserId, opt => opt.MapFrom(src => src.AssignedUserId)) .ForMember(dest => dest.CreatorUserId, opt => opt.MapFrom(src => src.CreatorUserId)) .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Title)) .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description)) .ForMember(dest => dest.Estimate, opt => opt.MapFrom(src => src.Estimate)) .ForMember(dest => dest.TaskStatus, opt => opt.MapFrom(src => src.TaskStatus)) .ForMember(dest => dest.CreatedDate, opt => opt.MapFrom(src => src.CreatedDate)) .ForMember(dest => dest.LastEditDate, opt => opt.MapFrom(src => src.LastEditDate)) .ForMember(dest => dest.ViewedDate, opt => opt.MapFrom(src => src.ViewedDate)); CreateMap <TaskModelResult, TaskModelEntity>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)) .ForMember(dest => dest.AssignedUserId, opt => opt.MapFrom(src => src.AssignedUserId)) .ForMember(dest => dest.CreatorUserId, opt => opt.MapFrom(src => src.CreatorUserId)) .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Title)) .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description)) .ForMember(dest => dest.Estimate, opt => opt.MapFrom(src => src.Estimate)) .ForMember(dest => dest.TaskStatus, opt => opt.MapFrom(src => src.TaskStatus)) .ForMember(dest => dest.CreatedDate, opt => opt.MapFrom(src => src.CreatedDate)) .ForMember(dest => dest.LastEditDate, opt => opt.MapFrom(src => src.LastEditDate)) .ForMember(dest => dest.ViewedDate, opt => opt.MapFrom(src => src.ViewedDate)); CreateMap <UserModelEntity, UserModelResult>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)) .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FirstName)) .ForMember(dest => dest.LastName, opt => opt.MapFrom(src => src.LastName)) .ForMember(dest => dest.Email, opt => opt.MapFrom(src => src.Email)) .ForMember(dest => dest.Password, opt => opt.MapFrom(src => src.Password)) .ForMember(dest => dest.ConfirmPassword, opt => opt.Ignore()) .ForMember(dest => dest.OrganizationName, opt => opt.MapFrom(src => src.OrganizationName)); CreateMap <UserModelResult, UserModelEntity>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id)) .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FirstName)) .ForMember(dest => dest.LastName, opt => opt.MapFrom(src => src.LastName)) .ForMember(dest => dest.Email, opt => opt.MapFrom(src => src.Email)) .ForMember(dest => dest.Password, opt => opt.MapFrom(src => src.Password)) .ForMember(dest => dest.OrganizationName, opt => opt.MapFrom(src => src.OrganizationName)); }
public IActionResult GetImage(int id, int imageNum) { Product product = _repository.GetproductById(id); var photo1 = new PhotoHelper(product.PhotoAvatar1, product.ImageName1, product.PhotoFile1, product.ImageMimeType1); var photo2 = new PhotoHelper(product.PhotoAvatar2, product.ImageName2, product.PhotoFile2, product.ImageMimeType2); var photo3 = new PhotoHelper(product.PhotoAvatar3, product.ImageName3, product.PhotoFile3, product.ImageMimeType3); PhotoHelper image = photo1; if (imageNum == 2) { image = photo2; } else if (imageNum == 3) { image = photo3; } if (image != null) { string webRootpath = _environment.WebRootPath; string folderPath = "\\Images\\"; string fullPath = webRootpath + folderPath + image.ImageName; if (System.IO.File.Exists(fullPath)) { FileStream fileOnDisk = new FileStream(fullPath, FileMode.Open); byte[] fileBytes; using (BinaryReader br = new BinaryReader(fileOnDisk)) { fileBytes = br.ReadBytes((int)fileOnDisk.Length); } return(File(fileBytes, image.ImageMimeType)); } else { if (image.PhotoFile.Length > 0) { return(File(image.PhotoFile, image.ImageMimeType)); } else { return(NotFound()); } } } else { return(NotFound()); } }
private async void checkedPinBtn_Click(object sender, RoutedEventArgs e) { LocationPin btnPin = ((Button)sender).DataContext as LocationPin; oldPin.IsSelected = false; oldPin = btnPin; oldPin.IsSelected = true; await LocationHelper.TryUpdateMissingLocationInfoAsync(btnPin, null); selectedImage.Source = await PhotoHelper.getImageSource(btnPin.Photo.ImageName); }
public void PhotoHelper_ConvertIDtoString_InValid_Bogus_Should_Fail() { // Arrange // Act var result = PhotoHelper.ConvertIDtoString("bogus"); // Reset // Assert Assert.AreEqual(string.Empty, result); }
public IActionResult Edit(ExperienceEditViewModel experienceEditVM) { if (ModelState.IsValid) { var product = _productRepository.GetProductUsingNameAndCategory(experienceEditVM.ProductName, int.Parse(experienceEditVM.CategoryID)); /*experienceEditVM.Category.CategoryName*/ if (product == null) { product = new Product { ProductName = experienceEditVM.ProductName, CategoryID = int.Parse(experienceEditVM.CategoryID) }; _productRepository.AddProduct(product); } string uniqueFileName = PhotoHelper.SaveImageAndReturnUniqueFileName(experienceEditVM.Photo, _hostingEnvironment, "images/products"); if (!string.IsNullOrEmpty(uniqueFileName) && System.IO.File.Exists("wwwroot/images/products/" + experienceEditVM.ExistingPhotoPath)) { try { System.IO.File.Delete("wwwroot/images/products/" + experienceEditVM.ExistingPhotoPath); } catch { } } var photoPath = uniqueFileName ?? experienceEditVM.ExistingPhotoPath; var experience = new Experience { ExperienceID = experienceEditVM.ExperienceID, ProductID = product.ProductID, Evaluation = experienceEditVM.Evaluation, Describe = experienceEditVM.Describe, Recommendation = experienceEditVM.Recommendation, UserName = User.FindFirst(ClaimTypes.Name).Value, PhotoPath = photoPath, Date = DateTime.Now }; var updateExperience = _experienceRepository.UpdateExperience(experience); return(RedirectToAction("details", new { experienceID = updateExperience.ExperienceID })); } return(View()); }
async Task ExecuteGalleryPhotoCommand() { using (PhotoHelper Photo = new PhotoHelper()) { await Photo.BuscarFoto(App.LarguraTela, App.LarguraTela); if (Photo.FotoColetada) { NewPet.Photo = Photo.ImagemBytes; ImagePet = Photo.GetImageSource(); } } }
private void FaceApiWorker_DoWorkAsync(object sender, DoWorkEventArgs e) { using (GalliumContext ctx = new GalliumContext()) { List <PhotoDirectories> directories = ctx.Directories.ToList(); IList <Photo> photos = PhotoHelper.DiscoverPhotosInDirectories(directories); AddPhotosToDB(ctx, photos); var uncheckedPhotos = ctx.Photos.Where(p => p.HasFacesChecked == false).ToList(); DetectFacesOnPhotosAsync(ctx, uncheckedPhotos); } }
public void TestInitializer() { serializer = new SerializerImp(); var rawJson = "[{'albumId':1,'id':9,'title':'accusamus beatae ad facilis vol similique qui dolor','url':'http://placehold.it/600/92c952','thumbnailUrl':'http://placehold.it/150/92c952'},{'albumId':1,'id':2,'title':'reprehenderit est deserunt velit dolor','url':'http://placehold.it/600/771796','thumbnailUrl':'http://placehold.it/150/771796'},{'albumId':1,'id':3,'title':'officia porro iure quia iusto qui ipsa ut modi','url':'http://placehold.it/600/24f355/vol','thumbnailUrl':'http://placehold.it/150/24f355'},{'albumId':1,'id':4,'title':'culpa odio esse rerum omnis laboriosam voluptate repudiandae','url':'http://placehold.it/600/d32776','thumbnailUrl':'http://placehold.it/150/d32776'},{'albumId':1,'id':5,'title':'natus nisi omnis corporis facere molestiae rerum in','url':'http://placehold.it/600/f66b97','thumbnailUrl':'http://placehold.it/150/f66b97'},{'albumId':1,'id':6,'title':'accusamus ea aliquid et amet sequi nemo','url':'http://placehold.it/600/56a8c2','thumbnailUrl':'http://placehold.it/150/56a8c2'}]"; var mocks = new MockRepository(MockBehavior.Default); client = mocks.Create <IRestClient>(); client.Setup(x => x.Get("https://jsonplaceholder.typicode.com/photos")).Returns(rawJson); client.Setup(x => x.HitCounter).Returns(2); helper = new PhotoHelper(client.Object, serializer); }
private async void HistoryDatePicker_DateChanged(object sender, DatePickerValueChangedEventArgs e) { HistoryDatePicker.IsHitTestVisible = false; HistoryDatePicker.Opacity = 0.5; var hasData = await GetPinsForGivenDate(); if (App.PageName.Equals("Start Trip")) { if (this.ViewModel.CheckedLocations.Count > 0) { oldPin = this.ViewModel.CheckedLocations[0]; oldPin.IsSelected = true; selectedImage.Source = await PhotoHelper.getImageSource(this.ViewModel.CheckedLocations[0].Photo.ImageName); } else if (this.ViewModel.PinnedLocations.Count > 0) { oldPin = this.ViewModel.PinnedLocations[0]; } else { oldPin = new LocationPin { DateCreated = HistoryDatePicker.Date, }; } } else if (App.PageName.Equals("End Trip")) { if (this.ViewModel.CheckedLocations.Count > 0) { oldPin = this.ViewModel.CheckedLocations[this.ViewModel.CheckedLocations.Count - 1]; oldPin.IsSelected = true; selectedImage.Source = await PhotoHelper.getImageSource(this.ViewModel.CheckedLocations[this.ViewModel.CheckedLocations.Count - 1].Photo.ImageName); } else if (this.ViewModel.PinnedLocations.Count > 0) { oldPin = this.ViewModel.PinnedLocations[this.ViewModel.PinnedLocations.Count - 1]; } else { oldPin = new LocationPin { DateCreated = HistoryDatePicker.Date, }; } } HistoryDatePicker.IsHitTestVisible = true; HistoryDatePicker.Opacity = 1; }
public void InvokeSaveAsMethod_Once_WhenBothParametersAreProvided() { // Arrange string physicalPath = @"c:\work\app_data"; var fileMock = new Mock <HttpPostedFileBase>(); IPhotoHelper photoHelper = new PhotoHelper(); // Act photoHelper.UploadToFileSystem(fileMock.Object, physicalPath); // Assert fileMock.Verify(x => x.SaveAs(It.IsAny <string>()), Times.Once); }
public IActionResult AddCategory(AddCategoryViewModel addCategoryVM) { if (ModelState.IsValid) { string uniqueFileName = PhotoHelper.SaveImageAndReturnUniqueFileName(addCategoryVM.Photo, _hostingEnvironment, "images/categories"); var category = new Category { CategoryName = addCategoryVM.CategoryName, CategoryPhotoPath = uniqueFileName }; _categoryRepository.AddCategory(category); return(RedirectToAction("ListCategories")); } return(View(addCategoryVM)); }
public void PhotoHelper_ToSelectListItemsTests_Valid_Should_Pass() { // Arrange var data = DataSourceBackend.Instance.PhotoBackend.Index(); // Act var result = PhotoHelper.ToSelectListItems(data, null); // Reset // Assert // Check each item returned, and make sure it matches the original data foreach (var item in result) { Assert.AreEqual(item.Text, data.Find(m => m.ID == item.Value).Note); } }