Example #1
0
        public FullUserDto ValidateUser(string email, string password)
        {
            using (var dbContext = new OmContext())
            {
                var user = dbContext.Users.FirstOrDefault(u => u.Email == email && u.Password == password);
                if (user != null)
                {
                    var userWithRoles = new FullUserDto
                    {
                        UserId    = user.UserId,
                        Name      = user.Name,
                        Email     = user.Email,
                        UserRoles = (from ur in dbContext.UserRoles
                                     join r in dbContext.Roles on ur.RoleId equals r.RoleId
                                     where ur.UserId == user.UserId
                                     select new RoleDto {
                            Title = r.Title
                        }).ToList(),
                        UserViews = (from uv in dbContext.UserViews
                                     join v in dbContext.Views on uv.ViewId equals v.ViewId
                                     where uv.UserId == user.UserId
                                     select new ViewDto {
                            Title = v.Title
                        }).ToList()
                    };
                    return(userWithRoles);
                }

                return(null);
            }
        }
        public async Task <FullUserDto> ReturnFullUser(User user)
        {
            var fullUser = new FullUserDto();

            fullUser.User    = _mapper.Map <UserDto>(user);
            fullUser.Profile = _mapper.Map <ProfileDto>(user.Profile);

            return(fullUser);
        }
Example #3
0
        public FullUserDto GetFullUser(int modelid)
        {
            var user = new FullUserDto(modelid)
            {
                Sin       = Factory.Billing.GetBalance(modelid),
                Transfers = Factory.Billing.GetTransfers(modelid),
                Rents     = Factory.Billing.GetRentas(modelid),
                Scoring   = Factory.Scoring.GetFullScoring(modelid),
                IsAdmin   = BillingHelper.IsAdmin(modelid)
            };

            return(user);
        }