示例#1
0
        private async void SharedPhoto_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            SharedPhoto tappedPhoto = ((TripTrak_2016.CustomControl.SharedPhoto)sender).DataContext as SharedPhoto;

            if (!string.IsNullOrEmpty(tappedPhoto.ImageName))
            {
                try
                {
                    StorageFile sourcePhoto = await KnownFolders.CameraRoll.GetFileAsync(tappedPhoto.ImageName);

                    IRandomAccessStream stream = await sourcePhoto.OpenAsync(FileAccessMode.Read);

                    if (sourcePhoto != null)
                    {
                        var imgSource = new BitmapImage();
                        imgSource.SetSource(stream);
                        EnlargeImage.Source         = imgSource;
                        EnlargeImageGrid.Visibility = Visibility.Visible;
                    }
                }
                catch (Exception ex)
                {
                    //
                }
            }
        }
 public ResultHelper Post([FromBody] SharedPhoto SharedPhoto)
 {
     if (SharedPhoto == null)
     {
         return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.UnSuccessMessage));
     }
     sharedPhotoService.Create(SharedPhoto);
     return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.SuccessMessage));
 }
示例#3
0
        public async Task <SharedEmailsListDTO> Handle(SharePhotoCommand request, CancellationToken cancellationToken)
        {
            SharedPhoto sharedPhoto = await SharePhotoAsync(request, cancellationToken);

            await NotifyUserAsync(sharedPhoto.SharedWithUserEmail, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            return(_mapper.Map <SharedEmailsListDTO>(sharedPhoto));
        }
        public ResultHelper Put(int id, [FromBody] SharedPhoto SharedPhoto)
        {
            if (SharedPhoto == null)
            {
                return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.UnSuccessMessage));
            }

            sharedPhotoService.Set(SharedPhoto);
            return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.SuccessMessage));
        }
        public ResultHelper Delete(int id)
        {
            SharedPhoto SharedPhoto = sharedPhotoService.Get(id);

            if (SharedPhoto == null)
            {
                return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.UnSuccessMessage));
            }

            sharedPhotoService.Delete(SharedPhoto);
            return(new ResultHelper(true, SharedPhoto.SharedPhotoID, ResultHelper.SuccessMessage));
        }
示例#6
0
        private async Task <SharedPhoto> SharePhotoAsync(SharePhotoCommand request, CancellationToken cancellationToken)
        {
            bool isPhotoAlreadyShared = await _context
                                        .Set <SharedPhoto>()
                                        .AnyAsync(sp => sp.PhotoId == request.PhotoId && sp.SharedWithUserEmail == request.UserEmail, cancellationToken);

            if (isPhotoAlreadyShared)
            {
                throw new PhotoIsAlreadySharedException(request.UserEmail);
            }

            SharedPhoto sharedPhoto = _mapper.Map <SharedPhoto>(request);
            await _context.Set <SharedPhoto>().AddAsync(sharedPhoto, cancellationToken);

            return(sharedPhoto);
        }
示例#7
0
        public async Task <Unit> Handle(DeleteSharedPhotoCommand request, CancellationToken cancellationToken)
        {
            SharedPhoto sharingToRemove = await _context
                                          .Set <SharedPhoto>()
                                          .FindAsync(new object[] { request.PhotoId, request.UserEmail }, cancellationToken);

            if (sharingToRemove == null)
            {
                throw new NotFoundException("Photo is not shared.");
            }

            _context.Set <SharedPhoto>().Remove(sharingToRemove);

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }