public async Task <bool> Delete(RatingStatus RatingStatus)
 {
     if (await ValidateId(RatingStatus))
     {
     }
     return(RatingStatus.IsValidated);
 }
Beispiel #2
0
        public void Delete(RatingStatus RatingStatus)
        {
            var existed = _context.RatingStatuses.Find(RatingStatus.Id);

            _context.RatingStatuses.Remove(existed);

            _context.SaveChanges();
        }
Beispiel #3
0
        internal void EditRating(RatingStatus ratingStatus, long editUserId)
        {
            if (OwnerId != editUserId)
            {
                throw new UserFriendlyException("You are not allowed to change this rating.");
            }

            RatingStatus = ratingStatus;
        }
Beispiel #4
0
        public async Task <RatingStatus> Get(long Id)
        {
            RatingStatus RatingStatus = await UOW.RatingStatusRepository.Get(Id);

            if (RatingStatus == null)
            {
                return(null);
            }
            return(RatingStatus);
        }
        public Company_RatingStatusDTO(RatingStatus RatingStatus)
        {
            this.Id = RatingStatus.Id;

            this.Name = RatingStatus.Name;

            this.Code = RatingStatus.Code;

            this.Errors = RatingStatus.Errors;
        }
Beispiel #6
0
 public WeeklyAverage GetWeeklyOnDateByPlayerId(int playerId, DateTime date, RatingStatus ratingStatus)
 {
     return(_context.WeeklyAverages.AsNoTracking()
            .FirstOrDefault(w => w.PlayerRating.PlayerId == playerId &&
                            w.Date.Date <= date &&
                            w.Date.Date >= date.AddDays(-7) &&
                            w.Type == "WeeklyAverage_Singles" &&
                            w.RatingStatus == ratingStatus
                            ));
 }
Beispiel #7
0
 private void PassSelectedSong(RatingStatus status)
 {
     if (!(SongsListView.SelectedItem is RatingFile selected))
     {
         return;
     }
     selected.Status = status;
     Files.First(f => f.Id == selected.Id).Status = status;
     OnPropertyChanged(nameof(Songs));
     SaveSongs();
 }
Beispiel #8
0
 public static Rating Create(RatingStatus ratingStatus, AbstractActivity abstractActivity, User owner)
 {
     return(new Rating
     {
         RatingStatus = ratingStatus,
         AbstractActivity = abstractActivity,
         AbstractActivityId = abstractActivity.Id,
         Owner = owner,
         OwnerId = owner.Id
     });
 }
Beispiel #9
0
 public static Rating Create(RatingStatus ratingStatus, ActivityPlan activityPlan, User owner)
 {
     return(new Rating
     {
         RatingStatus = ratingStatus,
         ActivityPlan = activityPlan,
         ActivityPlanId = activityPlan.Id,
         Owner = owner,
         OwnerId = owner.Id
     });
 }
Beispiel #10
0
        public void Update(RatingStatus ratingStatus)
        {
            var existed = _context
                          .RatingStatuses.Find(ratingStatus.Id);

            existed.Name        = ratingStatus.Name;
            existed.OrderNumber = ratingStatus.OrderNumber;
            existed.DemandMinNumberBooksAdded = ratingStatus.DemandMinNumberBooksAdded;
            existed.DemandMinNumberBooksGot   = ratingStatus.DemandMinNumberBooksGot;

            _context.SaveChanges();
        }
Beispiel #11
0
        public async Task <Rating> CreateAsync(RatingStatus ratingStatus, ActivityPlan activityPlan, User owner)
        {
            var rating = activityPlan.Ratings.FirstOrDefault(r => r.OwnerId == owner.Id && r.ActivityPlanId == activityPlan.Id);

            if (rating != null)
            {
                rating.EditRating(ratingStatus, owner.Id);
            }
            else
            {
                rating = await CreateAsync(Rating.Create(ratingStatus, activityPlan, owner));
            }

            return(rating);
        }
        public async Task <RatingStatus> Get(long Id)
        {
            RatingStatus RatingStatus = await DataContext.RatingStatus.AsNoTracking()
                                        .Where(x => x.Id == Id)
                                        .Select(x => new RatingStatus()
            {
                Id   = x.Id,
                Name = x.Name,
                Code = x.Code,
            }).FirstOrDefaultAsync();

            if (RatingStatus == null)
            {
                return(null);
            }

            return(RatingStatus);
        }
        public async Task <bool> ValidateId(RatingStatus RatingStatus)
        {
            RatingStatusFilter RatingStatusFilter = new RatingStatusFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = RatingStatus.Id
                },
                Selects = RatingStatusSelect.Id
            };

            int count = await UOW.RatingStatusRepository.Count(RatingStatusFilter);

            if (count == 0)
            {
                RatingStatus.AddError(nameof(RatingStatusValidator), nameof(RatingStatus.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Beispiel #14
0
        private Gallery(long id, EToken token, int recordCount)
            : base(recordCount)
        {
            Id         = id;
            Token      = token;
            Rating     = new RatingStatus(this);
            GalleryUri = new GalleryInfo(id, token).Uri;
            if (Client.Current.Settings.RawSettings.TryGetValue("tr", out var trv))
            {
                switch (trv)
                {
                case "1": _PageSize = 50; break;

                case "2": _PageSize = 100; break;

                case "3": _PageSize = 200; break;

                default: _PageSize = 20; break;
                }
            }
        }
Beispiel #15
0
 public IEnumerable <WeeklyAverage> GetAllWeeklyByPlayerId(int playerId, RatingStatus ratingStatus)
 {
     return(_context.WeeklyAverages.AsNoTracking()
            .Where(w => w.PlayerRating.PlayerId == playerId && w.Type == "WeeklyAverage_Singles")
            .Where(w => w.RatingStatus == ratingStatus));
 }
Beispiel #16
0
 private void UpdateAggregatedInfo(RatingStatus ratingStatus, FbUser ratingUser, bool isNewSong, bool isAdmin = false)
 {
     switch (ratingStatus)
     {
         case RatingStatus.AddedNewEmptyRating:
             if (isNewSong)
             {
                 NumberOfSongs++;
                 RewardUser(ratingUser, UserPlaylistInfo.Operation.AddSong, isAdmin);
             }
             break;
         case RatingStatus.AddedNewRating:
             if (isNewSong)
             {
                 NumberOfSongs++;
                 NumberOfVotes++;
                 RewardUser(ratingUser, UserPlaylistInfo.Operation.AddSong, isAdmin);
             }
             else
             {
                 NumberOfVotes++;
             }
             RewardUser(ratingUser, UserPlaylistInfo.Operation.RateSong, isAdmin);
             break;
         case RatingStatus.AddedRating:
             RewardUser(ratingUser, UserPlaylistInfo.Operation.RateSong, isAdmin);
             NumberOfVotes++;
             break;
         case RatingStatus.RemovedRating:
             NumberOfVotes--;
             RewardUser(ratingUser, UserPlaylistInfo.Operation.RemoveSongRating, isAdmin);
             break;
         default:
             break;
     }
 }
Beispiel #17
0
        public void Insert(RatingStatus ratingStatus)
        {
            _context.RatingStatuses.Add(ratingStatus);

            _context.SaveChanges();
        }
Beispiel #18
0
        public static void Initialize(this ApplicationContext context)
        {
            context.Database.EnsureCreated();

            // Look for any users.
            if (context.Users.Any())
            {
                return;                   // DB has been seeded
            }


            var adminRole = new Role {
                Name = "Admin"
            };
            var userRole = new Role {
                Name = "User"
            };
            var notRegisteredRole = new Role {
                Name = "NotRegistered"
            };


            var begginerStatus = new RatingStatus {
                Name = "Beginner", DemandMinNumberBooksAdded = 0, DemandMinNumberBooksGot = 0, OrderNumber = 0
            };
            var bookloverStatus = new RatingStatus {
                Name = "Booklover", DemandMinNumberBooksAdded = 1, DemandMinNumberBooksGot = 0, OrderNumber = 1
            };
            var megamindStatus = new RatingStatus {
                Name = "Megamind", DemandMinNumberBooksAdded = 8, DemandMinNumberBooksGot = 4, OrderNumber = 3
            };
            var bookWormStatus = new RatingStatus {
                Name = "BookWorm", DemandMinNumberBooksAdded = 10, DemandMinNumberBooksGot = 4, OrderNumber = 4
            };

            #region Users



            var users = new User[]
            {
                new User {
                    FirstName    = "Danilo",
                    LastName     = "Belokha",
                    RegisteredOn = DateTime.UtcNow,
                    Password     = "******",
                    PhoneNumber  = "38098875654846",
                    Email        = "*****@*****.**",
                    Role         = notRegisteredRole,
                    RatingStatus = megamindStatus
                },
                new User {
                    FirstName    = "John",
                    LastName     = "Sena",
                    RegisteredOn = DateTime.UtcNow,
                    Password     = "******",
                    PhoneNumber  = "38098875654846",
                    Email        = "*****@*****.**",
                    Role         = userRole,
                    RatingStatus = begginerStatus
                },
                new User {
                    FirstName    = "Andriy",
                    LastName     = "Dyuk",
                    RegisteredOn = DateTime.UtcNow,
                    Password     = "******",
                    PhoneNumber  = "+380444444444",
                    Email        = "*****@*****.**",
                    Role         = adminRole,
                    RatingStatus = bookWormStatus
                                   //RatingStatusId = context.RatingStatuses.FirstOrDefault(s => s.OrderNumber == 5).Id,
                                   //RoleId = context.Roles.FirstOrDefault(r => r.Name == "Admin").Id
                },
                new User {
                    FirstName    = "Vova",
                    LastName     = "Kovi",
                    RegisteredOn = DateTime.UtcNow,
                    Password     = "******",
                    PhoneNumber  = "+380990573255",
                    Email        = "*****@*****.**",
                    Role         = adminRole,
                    RatingStatus = bookloverStatus
                }
            };

            foreach (User u in users)
            {
                context.Users.Add(u);
            }
            context.SaveChanges();

            #endregion Users

            var ratingStatuses = new RatingStatus[]
            {
                new RatingStatus {
                    Name = "Experienced", DemandMinNumberBooksAdded = 2, DemandMinNumberBooksGot = 1, OrderNumber = 2
                },
                new RatingStatus {
                    Name = "Master", DemandMinNumberBooksAdded = 20, DemandMinNumberBooksGot = 15, OrderNumber = 5
                },
            };
            foreach (RatingStatus s in ratingStatuses)
            {
                context.RatingStatuses.Add(s);
            }
            context.SaveChanges();


            var genres = new Genre[]
            {
                new Genre {
                    Name = "Arts & Photography"
                },
                new Genre {
                    Name = "Biographies & Memoirs"
                },
                new Genre {
                    Name = "Business & Money"
                },
                new Genre {
                    Name = "Calendars"
                },
                new Genre {
                    Name = "Children's Books"
                },
                new Genre {
                    Name = "Christian Books & Bibles"
                },
                new Genre {
                    Name = "Comics & Graphic Novels"
                },
                new Genre {
                    Name = "Computers & Technology"
                },
                new Genre {
                    Name = "Cookbooks, Food & Wine"
                },
                new Genre {
                    Name = "Crafts, Hobbies & Home"
                },
                new Genre {
                    Name = "Education & Teaching"
                },
                new Genre {
                    Name = "Engineering & Transportation"
                },
                new Genre {
                    Name = "Gay & Lesbian"
                },
                new Genre {
                    Name = "Health, Fitness & Dieting"
                },
                new Genre {
                    Name = "History"
                },
                new Genre {
                    Name = "Humor & Entertainment"
                },
                new Genre {
                    Name = "Law"
                },
                new Genre {
                    Name = "Literature & Fiction"
                },
                new Genre {
                    Name = "Medical Books"
                },
                new Genre {
                    Name = "Mystery, Thriller & Suspense"
                },
                new Genre {
                    Name = "Parenting & Relationships"
                },
                new Genre {
                    Name = "Politics & Social Sciences"
                },
                new Genre {
                    Name = "Reference"
                },
                new Genre {
                    Name = "Religion & Spirituality"
                },
                new Genre {
                    Name = "Romance"
                },
                new Genre {
                    Name = "Science & Math"
                },
                new Genre {
                    Name = "Science Fiction & Fantasy"
                },
                new Genre {
                    Name = "Self-Help"
                },
                new Genre {
                    Name = "Sports & Outdoors"
                },
                new Genre {
                    Name = "Teen & Young Adult"
                },
                new Genre {
                    Name = "Test Preparation"
                },
                new Genre {
                    Name = "Travel"
                }
            };

            #region Books

            var books = new Book[]
            {
                new Book {
                    Title     = "Don Quixote",
                    Author    = "Miguel de Cervantes Saavedra",
                    CreatedOn = DateTime.UtcNow,
                    PrintedOn = new DateTime(1997, 3, 27),
                    //ConributorId = context.Users.FirstOrDefault( u => u.PhoneNumber == "+380990573255").Id,
                    Price       = 10,
                    IsUsable    = true,
                    Description = "WITH AN INTRODUCTION BY HAROLD BLOOM Widely regarded as the world's first modern novel, and one of the funniest and most tragic books ever written, Don Quixote chronicles the famous picaresque adventures of the noble knight-errant Don Quixote de La Mancha and his faithful squire, Sancho Panza, as they travel through sixteenth-century Spain. Unless you read Spanish, you've never read Don Quixote.",
                    //CurrentUserId = context.Users.FirstOrDefault(u => u.PhoneNumber == "+380990573255").Id
                },
                new Book {
                    Title  = "War and Peace",
                    Author = "Leo Tolstoy",
                    //GenreId = context.Genres.FirstOrDefault(g => g.Name == "Romance").Id,
                    CreatedOn = DateTime.UtcNow,
                    PrintedOn = new DateTime(1887, 5, 26),
                    //ConributorId = context.Users.FirstOrDefault( u => u.PhoneNumber == "+380990573255").Id,
                    Price       = 100,
                    IsUsable    = true,
                    Description = "Epic in scale, War and Peace delineates in graphic detail events leading up to Napoleon's invasion of Russia, and the impact of the Napoleonic era on Tsarist society, as seen through the eyes of five Russian aristocratic families.",
                    //CurrentUserId = context.Users.FirstOrDefault(u => u.PhoneNumber == "+380990573255").Id
                },
                new Book {
                    Title  = "Moby Dick",
                    Author = "Herman Melville",
                    //GenreId = context.Genres.FirstOrDefault(g => g.Name == "Literature & Fiction").Id,
                    CreatedOn = DateTime.UtcNow,
                    PrintedOn = new DateTime(1996, 7, 26),
                    //ConributorId = context.Users.FirstOrDefault( u => u.PhoneNumber == "+380990573255").Id,
                    Price       = 49,
                    IsUsable    = true,
                    Description = "First published in 1851, Melville's masterpiece is, in Elizabeth Hardwick's words, \"the greatest novel in American literature.\" The saga of Captain Ahab and his monomaniacal pursuit of the white whale remains a peerless adventure story but one full of mythic grandeur, poetic majesty, and symbolic power. Filtered through the consciousness of the novel's narrator, Ishmael, Moby-Dick draws us into a universe full of fascinating characters and stories, from the noble cannibal Queequeg to the natural history of whales, while reaching existential depths that excite debate and contemplation to this day.",
                    //CurrentUserId = context.Users.FirstOrDefault(u => u.PhoneNumber == "+380990573255").Id
                },
                new Book {
                    Title  = "The Divine Comedy",
                    Author = "Dante Alighieri",
                    //GenreId = context.Genres.FirstOrDefault(g => g.Name == "Literature & Fiction").Id,
                    CreatedOn = DateTime.UtcNow,
                    PrintedOn = new DateTime(2001, 12, 12),
                    //ConributorId = context.Users.FirstOrDefault( u => u.PhoneNumber == "+380444444444").Id,
                    Price       = 77,
                    IsUsable    = true,
                    Description = "Belonging in the immortal company of the great works of literature, Dante Alighieri's poetic masterpiece, The Divine Comedy, is a moving human drama, an unforgettable visionary journey through the infinite torment of Hell, up the arduous slopes of Purgatory, and on to the glorious realm of Paradise — the sphere of universal harmony and eternal salvation.",
                    //CurrentUserId = context.Users.FirstOrDefault(u => u.PhoneNumber == "+380990573255").Id
                },
                new Book {
                    Title  = "The Adventures of Huckleberry Finn",
                    Author = "Mark Twain",
                    //GenreId = context.Genres.FirstOrDefault(g => g.Name == "Children's Books").Id,
                    CreatedOn = DateTime.UtcNow,
                    PrintedOn = new DateTime(2010, 10, 15),
                    //ConributorId = context.Users.FirstOrDefault( u => u.PhoneNumber == "+380990573255").Id,
                    Price       = 0,
                    IsUsable    = true,
                    Description = "Revered by all of the town's children and dreaded by all of its mothers, Huckleberry Finn is indisputably the most appealing child-hero in American literature. Unlike the tall-tale, idyllic world of Tom Sawyer, The Adventures of Huckleberry Finn is firmly grounded in early reality. From the abusive drunkard who serves as Huckleberry's father, to Huck's first tentative grappling with issues of personal liberty and the unknown, Huckleberry Finn endeavors to delve quite a bit deeper into the complexities — both joyful and tragic of life.",
                    //CurrentUserId = context.Users.FirstOrDefault(u => u.PhoneNumber == "+380444444444").Id
                }
            };


            foreach (Book b in books)
            {
                context.Books.Add(b);
            }
            context.SaveChanges();

            #endregion Books
        }
 public async Task <bool> Create(RatingStatus RatingStatus)
 {
     return(RatingStatus.IsValidated);
 }
Beispiel #20
0
 public void EditRating(Rating rating, RatingStatus ratingStatus, long editUserId)
 {
     rating.EditRating(ratingStatus, editUserId);
 }