IQueryable <UserDto> CreateQuery(int _userId)
 {
     return(from u in contextDb.Set <User>()
            from g in contextDb.Set <UserGroup>().Where(g => g.Id == u.UserGroupId)
            .Where(x => u.Id == _userId)
            select new UserDto
     {
         Login = u.Login,
         Name = u.Name,
         UserGroupTitle = g.Name,
         AvatarUrl = u.AvatarUrl
     });
 }
Beispiel #2
0
 IQueryable <UserDto> CreateQuery()
 {
     return(from u in _context.Set <User>()
            from g in _context.Set <UserGroup>().Where(i => i.Id == u.UserGroupId)
            select new UserDto
     {
         Id = u.Id,
         Name = u.Name,
         Login = u.Login,
         IsGeneral = u.IsGeneral,
         UserGroupTitle = g.Name
     });
 }
 IQueryable <AchivmentModelView> CreateQuery(int _userId, int _count)
 {
     return(from u in baseContent.Set <UserAchivment>()
            from a in baseContent.Set <AchivmentType>().Where(a => a.Id == u.AchivnedTypeId)
            from g in baseContent.Set <User>().Where(i => i.Id == u.UserId && (u.UserId == _userId || _userId == 0))
            .OrderBy(x => u.Date)
            .OrderByDescending(x => u.Date)
            .Take(_count)
            select new AchivmentModelView
     {
         Date = u.Date,
         AchivmentComment = u.Comment,
         AchivmentName = a.Comment,
         UserName = g.Name
     });
 }
        public ActionResult GetRatingList()
        {
            List <User>      userList;
            List <UserGroup> groupsList;
            List <User>      userMoneyList;

            using (MotivationDb context = new MotivationDb())
            {
                userList      = context.Set <User>().OrderBy(x => x.Exp).OrderByDescending(x => x.Exp).Take(4).ToList();
                groupsList    = context.Set <UserGroup>().Take(3).ToList();
                userMoneyList = context.Set <User>().Where(x => x.CoinsCount > 0).OrderByDescending(x => x.CoinsCount).Take(4).ToList();
            }

            ViewBag.Groups    = groupsList;
            ViewBag.MoneyList = userMoneyList;
            return(View("GetRating", userList));
        }
 IQueryable <AchivmentAttempDto> CreateQuery()
 {
     return(from aa in _db.Set <AchivmentAttemp>()
            from au in _db.Set <User>().Where(i => i.Id == aa.AcceptUserId).DefaultIfEmpty()
            from aug in _db.Set <UserGroup>().Where(i => i.Id == au.UserGroupId).DefaultIfEmpty()
            from at in _db.Set <AchivmentType>().Where(i => i.Id == aa.AchivnedTypeId)
            select new AchivmentAttempDto
     {
         Id = aa.Id,
         Comment = aa.Comment,
         UserId = aa.UserId,
         CreateDate = aa.CreateDate,
         FileExt = aa.FileExt,
         FileName = aa.FileName,
         FileUrl = aa.FileUrl,
         IsAccepted = aa.IsAccepted,
         IsCompleted = aa.IsCompleted,
         AcceptUserName = au.Name,
         AcceptUserGroupName = aug.Name,
         AchivmentTypeComment = at.Comment,
         AchivmentTypeMaxCount = at.MaxCount,
         AchivmentTypeExpCount = at.ExpCount,
         AchivmentTypeCoinsCount = at.CoinsCount,
         AchivmentTypeImageUrl = at.ImageUrl
     });
 }
        public ActionResult GetCompetitions()
        {
            List <Compitition> competitionList;

            using (MotivationDb context = new MotivationDb())
            {
                competitionList = context.Set <Compitition>().ToList();
            }
            return(View(competitionList));
        }
        public ActionResult GetDepartmentList()
        {
            List <UserGroup> groupsList;

            using (MotivationDb context = new MotivationDb())
            {
                groupsList = context.Set <UserGroup>().ToList();
            }
            return(View(groupsList));
        }
Beispiel #8
0
        public IQueryable <CompititionDto> GetByUserId(int userId)
        {
            var query = from u in _context.Set <User>()
                        from g in _context.Set <UserGroup>().Where(i => i.Id == u.UserGroupId)
                        from cross in _context.Set <CompititionGroup>().Where(i => i.UserGroupId == g.Id)
                        where u.Id == userId
                        select cross.CompititionId;
            var ids = query.ToList();

            return(from c in _context.Set <Compitition>()
                   where ids.Contains(c.Id)
                   select new CompititionDto
            {
                Id = c.Id,
                Comment = c.Comment,
                EndDate = c.EndDate,
                ImageUrl = c.ImageUrl,
                StartDate = c.StartDate
            });
        }
Beispiel #9
0
 public ActionResult Logon(string txtUserName, string txtUserPass)
 {
     using (MotivationDb context = new MotivationDb())
     {
         User user = context.Set <User>().Where(x => x.Login == txtUserName && x.Password == txtUserPass).FirstOrDefault();
         if (user != null)
         {
             Session["UserId"] = user.Id;
             return(RedirectToAction("Home", "Index"));
         }
     }
     return(View("Login"));
 }