Ejemplo n.º 1
0
 public ShikimoriClient(ILogger logger, ClientSettings settings)
 {
     Client       = new ApiClient(logger, settings);
     Achievements = new Achievements(Client);
     Animes       = new Animes(Client);
     Bans         = new Bans(Client);
     Calendars    = new Calendars(Client);
     Characters   = new Characters(Client);
     Clubs        = new Clubs(Client);
     Comments     = new Comments(Client);
     Constants    = new Constants(Client);
     Dialogs      = new Dialogs(Client);
     Favorites    = new Favorites(Client);
     Forums       = new Forums(Client);
     Friends      = new Friends(Client);
     Genres       = new Genres(Client);
     Mangas       = new Mangas(Client);
     Messages     = new Messages(Client);
     People       = new People(Client);
     Publishers   = new Publishers(Client);
     Ranobe       = new Ranobe(Client);
     Stats        = new Stats(Client);
     Studios      = new Studios(Client);
     Styles       = new Styles(Client);
     TopicIgnores = new TopicIgnores(Client);
     Topics       = new Topics(Client);
     UserImages   = new UserImages(Client);
     UserRates    = new UserRates(Client);
     Users        = new Users(Client);
     Videos       = new Videos(Client);
 }
Ejemplo n.º 2
0
        public RedirectToActionResult RemoveRating(int UserId, int CurrentUserId)
        {
            UserRates thisRate = dbContext.UserRates
                                 .FirstOrDefault(ur => ur.UserId == UserId && ur.CurUser == CurrentUserId);

            User user = dbContext.Users
                        .Include(u => u.UserRates)
                        .FirstOrDefault(u => u.UserId == UserId);

            dbContext.UserRates.Remove(thisRate);
            dbContext.SaveChanges();

            user.allRatings -= thisRate.Rating;

            if (user.UserRates.Count == 0)
            {
                user.Rating = 0;
            }
            else
            {
                user.Rating = (user.allRatings / user.UserRates.Count);
            }

            dbContext.SaveChanges();

            return(RedirectToAction("ViewUser", new{ UserId = UserId }));
        }
Ejemplo n.º 3
0
        public async Task <string> Rate([FromBody] UserRateModel model)
        {
            try
            {
                if (model.Id != null)
                {
                    var entity = await _userRates.GetTAsync(x => x.Id == new Guid(model.Id));

                    entity.Rate = model.Rate;
                    var response = await _userRates.UpdateAsync(entity);
                }
                else
                {
                    UserRates entity      = _mapper.Map <UserRates>(model);
                    var       addedEntity = await _userRates.AddAsync(entity);

                    return(addedEntity.Id.ToString());
                }
            }
            catch (Exception e)
            {
                return("403");
            }

            return(model.Id);
        }
Ejemplo n.º 4
0
        public IActionResult UserRating(UserInfoViewModel submittedRating, int UserId)
        {
            UserRates newRate = new UserRates();

            newRate.UserId  = UserId;
            newRate.CurUser = (int)HttpContext.Session.GetInt32("InSession");
            newRate.Rating  = submittedRating.UserInfo.allRatings;

            dbContext.UserRates.Add(newRate);
            dbContext.SaveChanges();

            User user = dbContext.Users
                        .Include(u => u.UserRates)
                        .FirstOrDefault(u => u.UserId == UserId);

            user.allRatings += submittedRating.UserInfo.allRatings;
            user.Rating      = (user.allRatings / user.UserRates.Count);
            dbContext.SaveChanges();

            return(RedirectToAction("ViewUser", new{ UserId = UserId }));
        }
Ejemplo n.º 5
0
        private int compare(UserRates i_First, UserRates i_Second)
        {
            int compareScore = i_First.UserRate.CompareTo(i_Second.UserRate);

            return(compareScore);
        }