/// <summary>
        /// Returns a human readable string from a <see cref="PhotoStatus" /> value.
        /// </summary>
        /// <param name="photoStatus">The PhotoStatus object.</param>
        /// <returns>The human readable string.</returns>
        public static string ToReadableString(this PhotoStatus photoStatus)
        {
            switch (photoStatus)
            {
            case PhotoStatus.Active:
                return("Active");

            case PhotoStatus.Deleted:
                return("Deleted");

            case PhotoStatus.DoesntFitCategory:
                return("Does not fit category");

            case PhotoStatus.Hidden:
                return("Hidden");

            case PhotoStatus.ObjectionableContent:
                return("Objectionable content");

            case PhotoStatus.UnderReview:
                return("Under Review");

            default:
                return("Unknown");
            }
        }
Example #2
0
        public UserVIewModel LogIn(string email, string password)
        {
            var passwordHash = SHA256HashGenerator.GenerateHash(password);
            var userFromDb   = _trivagoSqlRepository.GetUsersByEmailAndPassword(email, passwordHash);

            if (userFromDb == null)
            {
                return(null);
            }
            var userDataInExpense = _trivagoSqlRepository.GetAllExpense()
                                    .Where(e => e.UserId == userFromDb.Id).ToList();

            if (userDataInExpense == null)
            {
                return(new UserVIewModel()
                {
                    Flag = "Zero"
                });
            }
            var everyPhotoStatus = new List <PhotoStatus>();

            foreach (var data in userDataInExpense)
            {
                var photoStatus = new PhotoStatus
                {
                    PhotoPath     = data.PhotoPath,
                    AprovalStatus = data.AprovalStatus
                };
                everyPhotoStatus.Add(photoStatus);
            }
            var userForView = _mapper.Map <UserVIewModel>(userFromDb);

            userForView.PhotoStatus = everyPhotoStatus;
            return(userForView);
        }
        /// <summary>
        /// Returns a human readable string from a <see cref="PhotoStatus" /> value.
        /// </summary>
        /// <param name="photoStatus">The PhotoStatus object.</param>
        /// <returns>The human readable string.</returns>
        public static string ToReadableString(this PhotoStatus photoStatus)
        {
            var resourceLoader = ResourceLoader.GetForCurrentView();

            switch (photoStatus)
            {
            case PhotoStatus.Active:
                return(resourceLoader.GetString("PhotoStatus_Active"));

            case PhotoStatus.Deleted:
                return(resourceLoader.GetString("PhotoStatus_Deleted"));

            case PhotoStatus.DoesntFitCategory:
                return(resourceLoader.GetString("PhotoStatus_DoesntFitCategory"));

            case PhotoStatus.Hidden:
                return(resourceLoader.GetString("PhotoStatus_Hidden"));

            case PhotoStatus.ObjectionableContent:
                return(resourceLoader.GetString("PhotoStatus_ObjectionableContent"));

            case PhotoStatus.UnderReview:
                return(resourceLoader.GetString("PhotoStatus_UnderReview"));

            default:
                return(resourceLoader.GetString("PhotoStatus_Unknown"));
            }
        }
Example #4
0
        public bool UpdatePhotoStatus(Guid guid, PhotoStatus photoStatus)
        {
            var entity = _photoRepository.SingleAttached(p => p.Guid == guid);

            entity.Status = (byte)photoStatus;
            _photoRepository.Save();
            return(true);
        }
        private HttpResponseMessage DoUpdatePhotoStatus(int id, string filename, PhotoStatus condStatus, PhotoStatus status, string error)
        {
            Photo photo = GetPhotoFromId(id)
                          .Where(p => p.Filename.Equals(filename, StringComparison.InvariantCultureIgnoreCase) && p.Status == (byte)condStatus).SingleOrDefault();

            if (photo == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, string.Format("Unexpected error: The {0} photo not found as {1} in the database.", filename, condStatus.ToString())));
            }

            photo.Error  = error;
            photo.Status = (byte)status;
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Example #6
0
        public UserVIewModel LogedUser(int id)
        {
            var user             = _trivagoSqlRepository.GetEmployee(id);
            var exp              = _trivagoSqlRepository.GetAllExpense().Where(x => x.UserId == user.Id).ToList();
            var everyPhotoStatus = new List <PhotoStatus>();

            foreach (var item in exp)
            {
                var photoStatus = new PhotoStatus
                {
                    PhotoPath     = item.PhotoPath,
                    AprovalStatus = item.AprovalStatus
                };
                everyPhotoStatus.Add(photoStatus);
            }
            var Loged = _mapper.Map <UserVIewModel>(user);

            Loged.PhotoStatus = everyPhotoStatus;
            return(Loged);
        }
Example #7
0
        private static IEnumerable <PhotoTDO> GetPhotos(Event ev, PhotoStatus status, int page, int pageSize, FotoShoutDbContext db)
        {
            IEnumerable <PhotoTDO> photos = ev.Photos.Where(p => p.Status == (byte)status).Select(p => new PhotoTDO {
                PhotoId     = p.PhotoId,
                Filename    = p.Filename,
                Folder      = p.Folder,
                Status      = p.Status,
                Submitted   = p.Submitted,
                SubmittedBy = p.SubmittedBy,
                Thumbnail   = AppConfigs.VirtualRoot + p.Thumbnail,
                Created     = p.Created,
                Image       = AppConfigs.VirtualRoot + ev.EventVirtualPath + "/" + Constants.STR_PROCESSED + "/" + p.Filename,
                Rating      = p.Rating
            });

            if (page > 0 && pageSize > 0 && (photos.Count() > pageSize))
            {
                return(photos.Skip((page - 1) * pageSize).Take(pageSize));
            }

            return(photos);
        }
        private HttpResponseMessage UpdatePhotoStatus(int id, string filename, PhotoStatus condStatus, PhotoStatus status, string error = "")
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);
            HttpResponseMessage response = null;

            try {
                response = DoUpdatePhotoStatus(id, filename, condStatus, status, error);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    db.SaveChanges();
                }
            }
            catch (DbUpdateConcurrencyException ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                this.GenerateException(HttpStatusCode.NotFound, ex.Message);
            }
            catch (Exception ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                this.GenerateException(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(response);
        }
Example #9
0
        private static IEnumerable <PhotoTDO> GetPhotosByGuest(Event ev, string name, PhotoStatus status, int page, int pageSize, FotoShoutDbContext db)
        {
            IEnumerable <Guest> guests = ev.Guests.Where(g => (g.FirstName + " " + g.LastName + " " + g.MiddleInitial).Contains(name, StringComparison.InvariantCultureIgnoreCase));
            HashSet <PhotoTDO>  photos = new HashSet <PhotoTDO>();

            foreach (Guest guest in guests)
            {
                IEnumerable <PhotoTDO> ps = guest.GuestPhotos.Where(gp => gp.Photo.Event.EventId == ev.EventId && gp.Photo.Status == (byte)status).Select(gp => new PhotoTDO {
                    PhotoId     = gp.Photo.PhotoId,
                    Filename    = gp.Photo.Filename,
                    Folder      = gp.Photo.Folder,
                    Status      = gp.Photo.Status,
                    Submitted   = gp.Photo.Submitted,
                    SubmittedBy = gp.Photo.SubmittedBy,
                    Thumbnail   = AppConfigs.VirtualRoot + gp.Photo.Thumbnail,
                    Created     = gp.Photo.Created,
                    Image       = AppConfigs.VirtualRoot + ev.EventVirtualPath + "/" + Constants.STR_PROCESSED + "/" + gp.Photo.Filename,
                    Rating      = gp.Photo.Rating
                });
                photos.UnionWith(ps);
            }

            return((page > 0 && pageSize > 0 && (photos.Count() > pageSize)) ?
                   photos.Distinct(new PhotoComparer <PhotoTDO>()).Skip((page - 1) * pageSize).Take(pageSize) : photos.Distinct(new PhotoComparer <PhotoTDO>()));
        }
Example #10
0
 public bool UpdatePhotoStatus(Guid guid, PhotoStatus photoStatus)
 {
     var entity = _photoRepository.SingleAttached(p => p.Guid == guid);
     entity.Status = (byte)photoStatus;
     _photoRepository.Save();
     return true;
 }
 public Task <PagedResponse <PhotoContract> > GetPhotosWithStatus(PhotoStatus status)
 {
     throw new NotImplementedException();
 }
 public Task<PagedResponse<PhotoContract>> GetPhotosWithStatus(PhotoStatus status)
 {
     throw new NotImplementedException();
 }
        private HttpResponseMessage UpdateClaimingPhotoStatus(int id, string filename, PhotoStatus status)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                if (status == PhotoStatus.Unclaimed)
                {
                    PhotoAnnotationService.MovePhoto(ev.EventFolder, Constants.STR_UNCLAIMED, filename);
                }
                else if (status == PhotoStatus.Unselected)
                {
                    PhotoAnnotationService.RestorePhoto(ev.EventFolder, Constants.STR_UNCLAIMED, filename);
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex) {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.ToString()));
            }
        }
 private IQueryable <Photo> GetPhotoFromId(int id, PhotoStatus status)
 {
     return(GetPhotoFromId(id).Where(p => p.Status == (byte)status));
 }
Example #15
0
 public void AddPhoto(string pFilename, PhotoStatus pStatus)
 {
     this.Add(new Photo(pFilename, pStatus));
 }
        /// <summary>
        /// Gets the list of photos with a specific status.
        /// </summary>
        /// <param name="status">The photo status.</param>
        /// <returns>A list of photos with provided status.</returns>
        public async Task<PagedResponse<PhotoContract>> GetPhotosWithStatus(PhotoStatus status)
        {
            var query = _documentClient.CreateDocumentQuery<PhotoDocument>(DocumentCollectionUri)
                .Where(d => d.DocumentType == PhotoDocument.DocumentTypeIdentifier)
                .Where(d => d.DocumentVersion == _currentDocumentVersion)
                .Where(p => p.Status == status);

            var documentQuery = query
                .OrderByDescending(p => p.CreatedDateTime.Epoch)
                .AsDocumentQuery();

            var documentResponse = await documentQuery.ExecuteNextAsync<PhotoDocument>();

            var photoContracts = await CreatePhotoContractsAndLoadUserData(documentResponse.ToList());

            var result = new PagedResponse<PhotoContract>
            {
                Items = photoContracts,
                ContinuationToken = documentResponse.ResponseContinuation
            };

            return result;
        }
Example #17
0
 private static int GetNumPhotos(Event ev, PhotoStatus status)
 {
     return(ev.Photos.Where(p => p.Status == (byte)status).Count());
 }
 /// <summary>
 /// Gets the list of photos with a specific status.
 /// </summary>
 /// <param name="status">The photo status.</param>
 /// <returns>A list of photos with provided status.</returns>
 public async Task <PagedResponse <PhotoContract> > GetPhotosWithStatus(PhotoStatus status)
 {
     return(await _repository.GetPhotosWithStatus(status));
 }
 /// <summary>
 /// Gets the list of photos with a specific status.
 /// </summary>
 /// <param name="status">The photo status.</param>
 /// <returns>A list of photos with provided status.</returns>
 public async Task<PagedResponse<PhotoContract>> GetPhotosWithStatus(PhotoStatus status)
 {
     return await _repository.GetPhotosWithStatus(status);
 }
Example #20
0
 public Photo(string pFilename, PhotoStatus pStatus)
 {
     this.Name     = Path.GetFileName(pFilename);
     this.Filename = pFilename;
     this.Status   = pStatus;
 }