/// <summary>
        /// Security status manager, current user information
        /// </summary>
        private void Authenticate()
        {
            try
            {
                ViewBag.padlock = Settings.gt_secure_img_padlock;
                if (System.Web.HttpContext.Current.Session[Settings.gt_ticketAccess] != null)
                {
                    isAuthenticate = (System.Web.HttpContext.Current.Session[Settings.gt_ticketAccess] == null ? false : true);
                    if (gt.UserName == string.Empty)
                    {
                        ModelCollection modelcollection = new ModelCollection();
                        modelcollection.AddModel(infoUser);
                        modelcollection.AddModel((System.Web.HttpContext.Current.Session[Settings.gt_ticketAccess].ToString()));
                        gt.controlPopulation(ref modelcollection, invokeRoutine.sel_adm_user_authenticate);
                    }
                }

                if (isAuthenticate)
                {
                    ViewBag.padlock        = Settings.gt_secure_img_padlock_unlock;
                    ViewBag.UserName       = infoUser.name;
                    ViewBag.UserPermission = infoUser.permission_nick;
                }
            }
            catch (Exception ex)
            {
                Register.Log(this, ref ex);
            }
        }
Exemple #2
0
        public ActionResult Index(int id = 0)
        {
            //Если в url не был представлен id пользователя, то явным образом вычисляем этот id
            //перенаправляем пользователя на то же действие, но добавляем в адрес вычесленный id
            if (id == 0)
            {
                return(RedirectToAction("Index", new { id = Membership.GetUser().ProviderUserKey }));
            }
            User user = dataManager.Users.GetUserById(id);

            //Исходя из значения id в url, определяем на чью страницу мы попали
            UserViewModel userViewModel = new UserViewModel
            {
                User                = user,
                UserIsMe            = id == (int)Membership.GetUser().ProviderUserKey,
                UserIsMyFriend      = dataManager.Friends.UsersAreFriends((int)Membership.GetUser().ProviderUserKey, user.Id),
                FriendRequestIsSent = dataManager.FriendRequests.RequestIsSent(user.Id, (int)Membership.GetUser().ProviderUserKey)
            };

            ////////////////////////////////////////////////////////////////////////////
            int currentUserId = (int)Membership.GetUser().ProviderUserKey;
            FriendsViewModel            friendsViewModel = new FriendsViewModel();
            IEnumerable <User>          allUsers         = dataManager.Users.GetUsers();
            IEnumerable <Friend>        allFriends       = dataManager.Friends.GetFriends().Where(x => x.FriendId == currentUserId);
            IEnumerable <FriendRequest> allRequests      = dataManager.FriendRequests.GetFriendRequests().Where(x => x.UserId == currentUserId || x.PossibleFriendId == currentUserId);
            IEnumerable <FriendRequest> incomingReuqests = allRequests.Where(x => x.UserId == currentUserId);

            friendsViewModel.IncomingRequests = (from aU in allUsers
                                                 from iR in incomingReuqests
                                                 where aU.Id == iR.PossibleFriendId
                                                 select aU);

            friendsViewModel.Friends = (from aU in allUsers
                                        from aF in allFriends
                                        where aU.Id == aF.UserId
                                        select aU);


            ///////////////////////////////////////////////////////////////////
            var modelCollection = new ModelCollection();

            modelCollection.AddModel(userViewModel);
            modelCollection.AddModel(friendsViewModel);
            return(View(modelCollection));
            //return View(model);
        }
Exemple #3
0
 /// <summary>
 /// Get user value, items restricted to user current
 /// </summary>
 /// <param name="authenticData">Object type: String, json data represents</param>
 public void getInfo(string authenticData)
 {
     if (authenticData != null)
     {
         if (authenticData != string.Empty)
         {
             ModelCollection modelcollection = new ModelCollection();
             modelcollection.AddModel(authenticData);
             gt.controlPopulation(ref modelcollection, Invoke.ORM.NameQuery.sel_adm_user_authenticate);
         }
     }
 }
        public IActionResult Search(string searchline)
        {
            List <SearchPart> parts = (List <SearchPart>)_parts.Partslistsearch(searchline);

            adorders.FillList(parts);


            var tr = new List <SearchPart>(parts);
            //tr = parts;
            var modelCollection = new ModelCollection();

            modelCollection.AddModel(tr);

            return(PartialView("Search", modelCollection));
        }
        public ActionResult Index()
        {
            int currentUserId      = (int)Membership.GetUser().ProviderUserKey;
            FriendsViewModel model = new FriendsViewModel();

            //Выбираем всех пользователей
            IEnumerable <User> allUsers = dataManager.Users.GetUsers();

            //ВЫбираем все заявки в друзья(входящие и исходящие)
            IEnumerable <FriendRequest> allRequests = dataManager.FriendRequests.GetFriendRequests().Where(x => x.UserId == currentUserId || x.PossibleFriendId == currentUserId);

            //Из всех заявок выбираем входящие
            IEnumerable <FriendRequest> incomingReuqests = allRequests.Where(x => x.UserId == currentUserId);

            //Из всех заявок выбираем исходящие
            IEnumerable <FriendRequest> outgoingRequests = allRequests.Where(x => x.PossibleFriendId == currentUserId);

            //По Id из входящих заявок выбираем соотвутствующих user и передаем их в модель
            model.IncomingRequests = (from aU in allUsers
                                      from iR in incomingReuqests
                                      where aU.Id == iR.PossibleFriendId
                                      select aU);

            //То же и с исходящими заявками
            model.OutgoingRequests = (from aU in allUsers
                                      from iR in outgoingRequests
                                      where aU.Id == iR.UserId
                                      select aU);

            //Выбираем все записи о друзьях для пользователя, кто сейчас залогинен
            IEnumerable <Friend> allFriends = dataManager.Friends.GetFriends().Where(x => x.FriendId == currentUserId);

            //По id из записей о друзьях выбираем соответствующих user и передаем в модель
            model.Friends = (from aU in allUsers
                             from aF in allFriends
                             where aU.Id == aF.UserId
                             select aU);

            var modelCollection = new ModelCollection();

            modelCollection.AddModel(model);
            return(View(modelCollection));
        }