Exemplo n.º 1
0
        public IHttpActionResult SetSimulationUsers(int id, [FromBody] SimulationUserModel[] simulationUsers)
        {
            UserInformationModel userInformation = ESECSecurity.GetUserInformation(Request);

            SimulationUserUpdateMethods[userInformation.Role](id, simulationUsers.ToList(), userInformation);
            return(Ok(simulationUsers));
        }
Exemplo n.º 2
0
        private void DisposeData(CommunicateObj obj)
        {
            if (UIModel != null)
            {
            }
            else
            {
                //如果是登录信息的话
                if (obj.DataType == CommunicateObj.DataTypeEnum.Login)
                {
                    LoginModel           liModel = obj.GetDataObj <LoginModel>();
                    UserInformationModel uiModel = UISQLControler.UnityIns.GetUserFromUserName(liModel.UserName);

                    //如果查找不到用户名
                    //密码错误
                    if ((uiModel == null) || (uiModel.Password != liModel.Password))
                    {
                        CommunicateObj objBack = new CommunicateObj(CommunicateObj.DataTypeEnum.LoginInBack, null, false, "用户名不存在");
                        this.SendMessage(objBack);
                    }
                    else
                    {
                        UIModel = uiModel;
                        CommunicateObj objBack = new CommunicateObj(CommunicateObj.DataTypeEnum.LoginInBack, uiModel, true, typeof(UserInformationModel));
                        this.SendMessage(objBack);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void Login()
        {
            UserValidationModel model = new UserValidationModel();

            model.LoginName = textBoxName.Text.TrimStart().TrimEnd();
            model.Password  = textBoxPassWord.Text;
            if (String.IsNullOrEmpty(model.LoginName) || String.IsNullOrEmpty(model.Password))
            {
                labelMessage.Text = "请录入登录信息";
            }
            else
            {
                HandlingResult   result = new HandlingResult();
                ValidationAction action = new ValidationAction();
                result = action.ValidateLogin(model);
                if (result.Successed)
                {
                    UserInformationModel user = (UserInformationModel)result.Result;
                    UserInformationContext.ID        = user.Id;
                    UserInformationContext.Name      = user.Name;
                    UserInformationContext.LoginName = user.LoginName;
                    UserInformationContext.LoginTime = DateTime.Now;
                    UserInformationContext.LoginPass = true;
                    UserInformationContext.StoreId   = "";
                    Close();
                }
                else
                {
                    labelMessage.Text = result.Message;
                }
            }
        }
        public MarketplaceItem CreateItemListing(UserInformationModel<User> aCreatingUser, ItemViewModel anItemViewModel)
        {
            if (!ValidItem(anItemViewModel)) {
                return null;
            }

            string myImageName = string.Empty;

            if (anItemViewModel.Image != null) {
                try {
                    myImageName = AWSPhotoHelper.TakeImageAndResizeAndUpload(anItemViewModel.Image,
                        AWSHelper.GetClient(),
                        SiteConfiguration.MarketplacePhotosBucket(),
                        anItemViewModel.Title.GetHashCode().ToString(),
                        MarketplaceConstants.ITEM_MAX_SIZE);
                } catch (Exception myException) {
                    throw new PhotoException("Unable to upload the image.", myException);
                }
            }

            MarketplaceItem myItem = theMarketplaceRepository.AddItemToMarketplace(
                anItemViewModel.UniversityId,
                aCreatingUser.Details,
                anItemViewModel.ItemType,
                anItemViewModel.Title,
                anItemViewModel.Description,
                double.Parse(anItemViewModel.Price),
                myImageName,
                TimeZoneInfo.ConvertTimeToUtc(DateTime.Parse(anItemViewModel.ExpireListing)));

            return myItem;
        }
Exemplo n.º 5
0
        //Changes forgotten password
        public async Task ForgotPasswordAsync(UserModel user, ForgotPasswordModel forgotPassword)
        {
            if (user.Status == (int)UserStatus.NotValid)
            {
                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("None Verified Email", "Your email is not verified");
                errors.Throw();
            }

            if (user.Status == (int)UserStatus.Banned)
            {
                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("User Is Banned", "User is banned from application");
                errors.Throw();
            }

            InformationModel ForgotPasswordVerificationCodeInfo = await _informationRepository.GetInformationByInformationNameAsync("ForgotPasswordVerificationCode");

            InformationModel ForgotPasswordVerificationCodeGenerateDateInfo = await _informationRepository.GetInformationByInformationNameAsync("ForgotPasswordVerificationCodeGenerateDate");

            UserInformationModel ForgotPasswordVerificationCode = await _userInformationRepository.GetUserInformationByIdAsync(user.Id, ForgotPasswordVerificationCodeInfo.Id);

            UserInformationModel ForgotPasswordVerificationCodeGenerateDate = await _userInformationRepository.GetUserInformationByIdAsync(user.Id, ForgotPasswordVerificationCodeGenerateDateInfo.Id);

            //Bad request
            if (ForgotPasswordVerificationCode == null)
            {
                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("Email Verification Code Not Exist", "There is no verification code which is generated for you");
                errors.Throw();
            }

            //Generated code timed out
            if (String.Format("{0:u}", DateTime.UtcNow.AddMinutes(-15)).CompareTo(ForgotPasswordVerificationCodeGenerateDate.Value) > 0)
            {
                _userInformationRepository.Delete(ForgotPasswordVerificationCode);
                _userInformationRepository.Delete(ForgotPasswordVerificationCodeGenerateDate);

                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("Verification Code Timeout", "Verification code timed out, please request another verification code");
                errors.Throw();
            }

            //Verification code accepted
            if (ForgotPasswordVerificationCode.Value == forgotPassword.VerificationCode)
            {
                user.Password = forgotPassword.NewPassword;
                _userRepository.Update(user);

                _userInformationRepository.Delete(ForgotPasswordVerificationCode);
                _userInformationRepository.Delete(ForgotPasswordVerificationCodeGenerateDate);
            }
            //Verification code does not matched
            else
            {
                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("Verification Code", "Verification code does not matched");
                errors.Throw();
            }
        }
Exemplo n.º 6
0
 public static bool IsAllowedToDelete(UserInformationModel<User> aCurrentUser, Board aBoardMessage)
 {
     return aCurrentUser !=null
         && (aCurrentUser.Details.Id == aBoardMessage.OwnerUserId
         || aCurrentUser.Details.Id == aBoardMessage.PostedUserId
         || PermissionHelper<User>.AllowedToPerformAction(aCurrentUser, SocialPermission.Delete_Any_Board_Message));
 }
Exemplo n.º 7
0
 public IEnumerable<UserStatus> GetLatestUserStatusesWithinUniversity(UserInformationModel<User> aUser,string aUniversityId, int aLimit)
 {
     return theUserStatusRepository
         .GetLatestUserStatuses(aUniversityId)
         .Where(s => FriendHelper.IsFriend(aUser.Details, s.User) || s.Everyone)
         .Take(aLimit); ;
 }
Exemplo n.º 8
0
        public SearchResultsModel GetAllSearchResults(UserInformationModel<User> aUserInformation, string aSearchString, int aPage)
        {
            IEnumerable<TextBook> myTextBooks = new List<TextBook>();
            IEnumerable<MarketplaceItem> myItems = new List<MarketplaceItem>();

            string myUniversityId = "All";

            if (aUserInformation != null) {
                myUniversityId = UniversityHelper.GetMainUniversity(aUserInformation.Details).Id;
                myTextBooks = theSearchRepository.GetTextBookByTitle(myUniversityId, aSearchString);
                myItems = theMarketplaceSerivce.GetLatestItemsSellingInUniversityByTitle(myUniversityId, aSearchString);
            } else {
                myTextBooks = theSearchRepository.GetTextBookByTitle(aSearchString);
                myItems = theMarketplaceSerivce.GetLatestItemsSellingByTitleForAllUniversitiesAndTypes(aSearchString);
            }

            List<ISearchResult> mySearchResult = new List<ISearchResult>();

            mySearchResult.AddRange(myTextBooks.Select(r => new TextBookSearchResult(r) {
                UserInformationModel = aUserInformation
            }));
            mySearchResult.AddRange(myItems.Select(r => new ItemSearchResult(r) {
                UserInformationModel = aUserInformation
            }));

            mySearchResult = mySearchResult.OrderByDescending(i => i.GetDateTime()).ToList();

            int myTotalResults = myItems.Count<MarketplaceItem>() + myTextBooks.Count<TextBook>();
            SearchResultsModel myModel =
                BuildSearchResultsModel(myUniversityId, mySearchResult, SearchFilter.ALL, aPage,
                                        aSearchString, myTotalResults, SearchByForAll(),
                                        SearchBy.None, OrderByForAll(), OrderBy.None);
            return myModel;
        }
Exemplo n.º 9
0
        public IHttpActionResult DeleteSimulation(int id)
        {
            UserInformationModel userInformation = ESECSecurity.GetUserInformation(Request);

            SimulationDeletionMethods[userInformation.Role](id, userInformation);
            return(Ok());
        }
Exemplo n.º 10
0
        private void LoadFormWithData()
        {
            if (_userInformationList == null || _userInformationList.Count <= 0)
            {
                _isAddNewMode = true;
                return;
            }

            _userInformation          = _userInformationList[_currentIndex];
            txtUserId.Text            = Convert.ToString(_userInformation.Id);
            cbxUserType.SelectedValue = _userInformation.UserTypeId;
            cbxEmployee.SelectedValue = _userInformation.EmployeeId;
            cbxRole.SelectedValue     = _userInformation.RoleId;
            txtUsername.Text          = _userInformation.Username;
            //txtPassword.Text = _userInformation.Password;
            txtPasswordAge.Text = Convert.ToString(_userInformation.PasswordAgeLimit);
            if (_userInformation.LastPasswordChangedDate != null)
            {
                txtLastPasswordChangedDate.Text = Convert.ToDateTime(_userInformation.LastPasswordChangedDate).ToString("dd-MMM-yyyy");
            }
            if (_userInformation.LastLockedDate != null)
            {
                txtLastLockedDate.Text = Convert.ToDateTime(_userInformation.LastLockedDate).ToString("dd-MMM-yyyy");
            }
            txtWrongPasswordTryLimit.Text = Convert.ToString(_userInformation.WrongPasswordTryLimit);
            chkIsPasswordChanged.Checked  = _userInformation.IsPasswordChanged;
            chkIsLocked.Checked           = _userInformation.IsLocked;
            chkIsSuperAdmin.Checked       = _userInformation.IsSuperAdmin;
            chkIsActive.Checked           = _userInformation.IsActive;

            dgvUserList.Rows[_currentIndex].Selected = true;
            dgvUserList.CurrentCell = dgvUserList.Rows[_currentIndex].Cells[0];
            _isChanged    = false;
            _isAddNewMode = false;
        }
Exemplo n.º 11
0
        public IHttpActionResult UpdateSimulation([FromBody] SimulationModel model)
        {
            UserInformationModel userInformation = ESECSecurity.GetUserInformation(Request);

            SimulationUpdateMethods[userInformation.Role](model, userInformation);
            return(Ok());
        }
Exemplo n.º 12
0
        private BaseFilterModel GetFilterForUserEnglishLevel(
            int neededCount,
            UserInformationModel userInformation,
            PerEnglishLevelTaskInformationModel userLevelInfo)
        {
            var totalCountOfUserLevelTasks = userLevelInfo.GrammarPartCount.Values.Sum();

            if (totalCountOfUserLevelTasks < neededCount)
            {
                return(null);
            }

            var countWithUsersGrammarParts = 0;

            foreach (var grammarPart in userInformation.FavouriteGrammarParts)
            {
                if (userLevelInfo.GrammarPartCount.TryGetValue(grammarPart, out int grammarPartCount))
                {
                    countWithUsersGrammarParts += grammarPartCount;
                }
            }

            if (countWithUsersGrammarParts >= neededCount)
            {
                return(BaseFilterModel.CreateFromUserInformation(userInformation));
            }

            var filterWithAllGrammarPartsForLevel = new BaseFilterModel();

            filterWithAllGrammarPartsForLevel.EnglishLevel = new[] { userInformation.EnglishLevel };
            filterWithAllGrammarPartsForLevel.GrammarPart  = userLevelInfo.GrammarPartCount.Keys.ToList();

            return(filterWithAllGrammarPartsForLevel);
        }
Exemplo n.º 13
0
        public ClassDetailsModel GetClass(UserInformationModel<User> aViewingUser, int aClassId, ClassViewType aClassViewType)
        {
            Class myClass = theClassRepository.GetClass(aClassId);

            return new ClassDetailsModel() {
                Class = myClass
            };
        }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a default UserCriteriaModel for a new user, based on their role.
 /// Administrators have full access by default.
 /// All other users have no access by default.
 /// </summary>
 /// <param name="userInformation">UserInformationModel</param>
 /// <returns>UserCriteriaModel</returns>
 private UserCriteriaModel GenerateDefaultUserCriteria(UserInformationModel userInformation) =>
 new UserCriteriaModel
 {
     Username    = userInformation.Name,
     Criteria    = null,
     HasCriteria = false,
     HasAccess   = userInformation.Role == Role.ADMINISTRATOR
 };
        public IEnumerable<AuthorityViewableZipCode> GetAuthorityViewableZipCodes(UserInformationModel<User> anAdminUser, string anEmail)
        {
            if (!PermissionHelper<User>.AllowedToPerformAction(anAdminUser, SocialPermission.Create_Authority_Verification_Token)) {
                throw new PermissionDenied(ErrorKeys.PERMISSION_DENIED);
            }

            return theAuthenticationRepo.GetAuthorityViewableZipCodes(anEmail);
        }
Exemplo n.º 16
0
    protected void ButtonRegister_Click(object sender, EventArgs e)
    {
        var userStore = new UserStore <IdentityUser>();


        userStore.Context.Database.Connection.ConnectionString =
            System.Configuration.ConfigurationManager.ConnectionStrings["db_1525657_sweethswixthshopConnectionString"].ConnectionString;
        var manager = new UserManager <IdentityUser>(userStore);


        var user = new IdentityUser {
            UserName = TextBoxUsername.Text
        };

        if (TextBoxPassword.Text == TextBoxConfirmPassword.Text)
        {
            try
            {
                IdentityResult result = manager.Create(user, TextBoxPassword.Text);
                if (result.Succeeded)
                {
                    UserInformation info = new UserInformation

                    {
                        Address  = TextAddress.Text,
                        Surname  = TextSurname.Text,
                        Forename = TextForename.Text,

                        GUID = user.Id
                    };

                    UserInformationModel model = new UserInformationModel();
                    model.InserUserInformation(info);



                    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
                    var userIdentity          = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);


                    authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    LiteralStatus.Text = result.Errors.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                LiteralStatus.Text = ex.ToString();
            }
        }
        else
        {
            LiteralStatus.Text = "Confirm Password dont match with your password!";
        }
    }
Exemplo n.º 17
0
 public void DeleteUserStatus(UserInformationModel<User> aUserInfo, int aStatusId)
 {
     UserStatus myUserStatus = theUserStatusRepository.GetUserStatus(aStatusId);
     if (aUserInfo.UserId == myUserStatus.UserId) {
         theUserStatusRepository.DeleteUserStatus(aStatusId);
     } else {
         throw new PermissionDenied(ErrorKeys.PERMISSION_DENIED);
     }
 }
Exemplo n.º 18
0
        //
        // GET: /User/Details/5

        public ActionResult Details(int id = 0)
        {
            User  userSelect  = db.Users.Find(id);
            Group groupSelect = db.Groups.Find(userSelect.GroupId);
            var   selectRole  = "";

            switch (userSelect.Role)
            {
            case 0:
                selectRole = "Студент";
                break;

            case 1:
                selectRole = "Преподаватель";
                break;

            case 2:
                selectRole = "Администратор";
                break;
            }
            UserInformationModel userInfo = new UserInformationModel
            {
                Id         = userSelect.Id,
                Email      = userSelect.Email,
                LastName   = userSelect.LastName,
                FirstName  = userSelect.FirstName,
                Date       = userSelect.Date,
                DateCreate = userSelect.DateCreate,
                Active     = userSelect.Active,
                Phone      = userSelect.Phone,
                Role       = selectRole,
                RoleId     = userSelect.Role
            };

            if (groupSelect == null)
            {
                userInfo.Group = "Группа не задана";
            }
            else
            {
                userInfo.Group = groupSelect.Name;
            }
            if (User.Identity.IsAuthenticated)
            {
                var userName = User.Identity.Name;
                var user     = userService.GetByName(userName);
                ViewBag.User     = user;
                ViewBag.Messages = messageService.GetRecepientNotReadCount(user.Id);
                ViewBag.Groups   = db.Groups.ToList();
            }
            if (userSelect == null)
            {
                return(HttpNotFound());
            }
            return(View(userInfo));
        }
Exemplo n.º 19
0
 public void UpdateFeatureSettings(UserInformationModel<User> aUser, UpdateFeaturesModel anUpdateFeaturesModel)
 {
     IEnumerable<Feature> myEnabledFeatures = (from f in anUpdateFeaturesModel.Features
                                               where f.Second
                                               select f.First);
     IEnumerable<Feature> myDisabledFeatures = (from f in anUpdateFeaturesModel.Features
                                                where !f.Second
                                                select f.First);
     theFeatureRepo.UpdateFeatureSettings(aUser.Details, myEnabledFeatures, myDisabledFeatures);
 }
Exemplo n.º 20
0
        public bool ApproveGroupMember(UserInformationModel<User> aUser, int aGroupMemberId, string aTitle, bool anAdministrator)
        {
            if (!ValidTitle(aTitle)) {
                return false;
            }

            theGroupRepository.ApproveGroupMember(aUser.Details, aGroupMemberId, aTitle, anAdministrator);

            return true;
        }
Exemplo n.º 21
0
        public bool ActivateGroup(UserInformationModel<User> aUser, int aGroupId)
        {
            if (!ValidateAdmin(aUser, aGroupId)) {
                return false;
            }

            theGroupRepository.ActivateGroup(aUser.Details, aGroupId);

            return true;
        }
Exemplo n.º 22
0
        public RedirectToRouteResult Entry()
        {
            UserInformationModel userInformation = TempData["UserInformation"] as UserInformationModel;

            TempData.Remove("UserInformation");
            if (Session["UserInformation"] == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            return(RedirectToAction("Home", "Admin", userInformation));
        }
        public static BaseFilterModel CreateFromUserInformation(UserInformationModel userInformation)
        {
            var englishLevels = new[] { userInformation.EnglishLevel };
            var filterModel   = new BaseFilterModel()
            {
                GrammarPart  = userInformation.FavouriteGrammarParts,
                EnglishLevel = englishLevels,
            };

            return(filterModel);
        }
Exemplo n.º 24
0
        public UserProfileModel AuthorityProfile(UserInformationModel<User> anAuthorityUserInformation)
        {
            User myAuthorityUser = anAuthorityUserInformation.Details;
            IEnumerable<Issue> myPeoplesIssues = new List<Issue>();
            IEnumerable<IssueReply> myPeoplesIssueReplies = new List<IssueReply>();

            string myAuthorityPosition = myAuthorityUser.UserPosition.Position.ToUpper();

            if (AuthorityClassification.GetAuthorityPostionsViewableByZip().Contains(myAuthorityPosition)) {
                myPeoplesIssues = theRepository.AuthorityIssuesFeedByZipCode(myAuthorityUser);
                myPeoplesIssueReplies = theRepository.AuthorityIssueReplysFeedByZipCode(myAuthorityUser);
            } else if (AuthorityClassification.GetAuthorityPostionsViewableByCityState().Contains(myAuthorityPosition)) {
                myPeoplesIssues = theRepository.AuthorityIssuesFeedByCityState(myAuthorityUser);
                myPeoplesIssueReplies = theRepository.AuthorityIssueReplysFeedByCityState(myAuthorityUser);
            } else if (AuthorityClassification.GetAuthorityPostionsViewableByState().Contains(myAuthorityPosition)) {
                myPeoplesIssues = theRepository.AuthorityIssuesFeedByState(myAuthorityUser);
                myPeoplesIssueReplies = theRepository.AuthorityIssueReplysFeedByState(myAuthorityUser);
            }

            List<IssueFeedModel> myIssueFeed = CreateIssueFeedForAuthority(myPeoplesIssues, anAuthorityUserInformation, PersonFilter.People).ToList<IssueFeedModel>();
            List<IssueReplyFeedModel> myIssueReplyFeed = CreateIssueReplyFeedForAuthority(myPeoplesIssueReplies, anAuthorityUserInformation, PersonFilter.People).ToList<IssueReplyFeedModel>();
            IEnumerable<IssueFeedModel> myPoliticiansIssueFeed = CreateIssueFeed(theRepository.IssueFeedByRole(UserRoleHelper.PoliticianRoles()), myAuthorityUser, PersonFilter.Politicians);
            IEnumerable<IssueReplyFeedModel> myPoliticiansIssueReplyFeed = CreateIssueReplyFeed(theRepository.IssueReplyFeedByRole(UserRoleHelper.PoliticianRoles()), myAuthorityUser, PersonFilter.Politicians);
            IEnumerable<IssueFeedModel> myPoliticalCandidateIssueFeed = CreateIssueFeed(theRepository.IssueFeedByRole(UserRoleHelper.PoliticalCandidateRoles()), myAuthorityUser, PersonFilter.PoliticalCandidates);
            IEnumerable<IssueReplyFeedModel> myPoliticalCandidateIssueReplyFeed = CreateIssueReplyFeed(theRepository.IssueReplyFeedByRole(UserRoleHelper.PoliticalCandidateRoles()), myAuthorityUser, PersonFilter.PoliticalCandidates);

            //myIssueFeed.AddRange(myPoliticiansIssueFeed);
            //myIssueFeed.AddRange(myPoliticalCandidateIssueFeed);
            myIssueFeed = myIssueFeed.OrderByDescending(i => i.DateTimeStamp).Take<IssueFeedModel>(10).ToList<IssueFeedModel>();

            //myIssueReplyFeed.AddRange(myPoliticiansIssueReplyFeed);
            //myIssueReplyFeed.AddRange(myPoliticalCandidateIssueReplyFeed);
            myIssueReplyFeed = myIssueReplyFeed.OrderByDescending(ir => ir.DateTimeStamp).Take<IssueReplyFeedModel>(10).ToList<IssueReplyFeedModel>();

            Issue myRandomLocalIssue = theRepository.RandomLocalIssue(myAuthorityUser);

            UserProfileModel myModel = new UserProfileModel(myAuthorityUser) {
                IssueFeed = myIssueFeed,
                IssueReplyFeed = myIssueReplyFeed,
            };

            Random myRandom = new Random();
            if (myRandom.Next() % 2 == 1) {
                if (!SetForLocalIssue(myModel, myAuthorityUser)) {
                    SetForFriendSuggestion(myModel, anAuthorityUserInformation);
                }
            } else {
                if (!SetForFriendSuggestion(myModel, anAuthorityUserInformation)) {
                    SetForLocalIssue(myModel, myAuthorityUser);
                }
            }

            return myModel;
        }
Exemplo n.º 25
0
        public UserInformationForm()
        {
            InitializeComponent();
            IKernel kernel = BootStrapper.Initialize();

            _userInformationService     = kernel.GetService(typeof(UserInformationService)) as UserInformationService;
            _userTypeService            = kernel.GetService(typeof(UserTypeService)) as UserTypeService;
            _employeeInformationService = kernel.GetService(typeof(EmployeeInformationService)) as EmployeeInformationService;
            _roleService = kernel.GetService(typeof(RoleService)) as RoleService;

            _userInformation = new UserInformationModel();
        }
Exemplo n.º 26
0
        public bool CreateUserStatus(UserInformationModel<User> aUserInfo, string aStatus, bool anEveryone)
        {
            if (!ValidStatus(aStatus)) {
                return false;
            }

            University myUniversity = UniversityHelper.GetMainUniversity(aUserInfo.Details);

            theUserStatusRepository.CreateUserStatus(aUserInfo.Details, myUniversity, aStatus, anEveryone);

            return true;
        }
        public WorkspaceViewModel(IScreen screen, UserInformationModel userInformation)
        {
            HostScreen      = screen;
            UserInformation = userInformation;

            Logout = ReactiveCommand.Create(() => { HostScreen.Router.NavigateAndReset.Execute(new LoginViewModel(HostScreen)); });
            Router.Navigate.Execute(new EmployeesViewModel(this));

            this.WhenActivated((CompositeDisposable disposables) =>
            {
            });
        }
Exemplo n.º 28
0
        public UniversityView GetUniversityProfile(UserInformationModel<User> aUserInformation, string aUniversityId)
        {
            University myUniversity = theUniversityRepository.GetUniversity(aUniversityId);
            IEnumerable<TextBook> myTextBooks = theTextBookService.GetTextBooksForUniversity(aUniversityId);
            IEnumerable<MarketplaceItem> myMarketplaceItems = theMarketplaceService.GetAllLatestItemsSellingInUniversity(aUniversityId);

            return new UniversityView() {
                University = myUniversity,
                TextBooks = myTextBooks,
                MarketplaceItems = myMarketplaceItems
            };
        }
Exemplo n.º 29
0
        public ActionResult Reset()
        {
            HttpCookie cookie = HttpContext.Request.Cookies.Get("Email");

            if (cookie != null)
            {
                UserInformationModel userInformationModel = new UserInformationModel();
                userInformationModel.email = cookie.Value;
                return(View(userInformationModel));
            }
            return(RedirectToAction("Login", "User"));
        }
        public IHttpActionResult SaveCriteriaDrivenBudgets(int id, [FromBody] List <CriteriaDrivenBudgetModel> models)
        {
            UserInformationModel userInformation = ESECSecurity.GetUserInformation(Request);
            var result = CriteriaDrivenBudgetsSaveMethods[userInformation.Role](id, models, userInformation);

            if (result.IsCompleted)
            {
                return(Ok());
            }

            return(NotFound());
        }
Exemplo n.º 31
0
        public IHttpActionResult SaveCommittedProjectsFiles()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new ConstraintException("The data provided is not a valid MIME type.");
            }

            UserInformationModel userInformation = ESECSecurity.GetUserInformation(Request);

            repo.SaveCommittedProjectsFiles(HttpContext.Current.Request, db, userInformation);
            return(Ok());
        }
Exemplo n.º 32
0
        //Admin request to user for inviting home
        public async Task InviteHomeRequestAsync(UserModel user, string invitedUsername)
        {
            Task <InformationModel> firstNameInfo = _informationRepository.GetInformationByInformationNameAsync("FirstName");
            Task <InformationModel> lastNameInfo  = _informationRepository.GetInformationByInformationNameAsync("LastName");

            if (user.Position != (int)UserPosition.Admin)
            {
                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("Authorisation Constraint", "You are not authorized for this request, you must be administrator of home");
                errors.Throw();
            }

            var home = (await _userRepository.GetByIdAsync(user.Id, true)).Home;

            //Admin waiting for user's accept

            UserModel invitedUser = await _userRepository.GetByUsernameAsync(invitedUsername);

            if (invitedUser == null)
            {
                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("User Not Exist", "User is not exist");
                errors.Throw();
            }

            if (invitedUser.Position != (int)UserPosition.HasNotHome)
            {
                CustomException errors = new CustomException((int)HttpStatusCode.BadRequest);
                errors.AddError("User Has Home", "You can not invite a user who already has home");
                errors.Throw();
            }

            UserInformationModel firstName = await _userInformationRepository.GetUserInformationByIdAsync(user.Id, (await firstNameInfo).Id);

            UserInformationModel lastName = await _userInformationRepository.GetUserInformationByIdAsync(user.Id, (await lastNameInfo).Id);

            FCMModel fcm = new FCMModel(invitedUser.DeviceId, new Dictionary <string, object>());

            fcm.notification.Add("title", "Eve Katılma Daveti");
            fcm.notification.Add("body", String.Format("{0} {1}({2}) evine katılmanız için davet ediyor.", firstName.Value, lastName.Value, user.Username));

            await _fcmService.SendFCMAsync(fcm);

            fcm = new FCMModel(invitedUser.DeviceId, type: "InviteHomeRequest");

            fcm.data.Add("InvitedHomeId", home.Id);
            fcm.data.Add("InviterUsername", user.Username);
            fcm.data.Add("InviterFirstName", firstName.Value);
            fcm.data.Add("InviterLastName", lastName.Value);

            await _fcmService.SendFCMAsync(fcm);
        }
Exemplo n.º 33
0
        public Class CreateClass(UserInformationModel<User> aCreatedByUser, CreateClassModel aCreateClassModel)
        {
            if (!ValidClass(aCreateClassModel)) {
                return null;
            }

            Class myClass= theClassRepository.CreateClass(aCreatedByUser.Details, aCreateClassModel.UniversityId,
                                                          aCreateClassModel.ClassSubject.Trim().ToUpper(),
                                                          aCreateClassModel.ClassCourse.Trim().ToUpper(),
                                                          aCreateClassModel.ClassTitle.Trim());

            return myClass;
        }
Exemplo n.º 34
0
        public double CalculateBMI(UserInformationModel userInformationModel)
        {
            double result = 0.0;

            if (userInformationModel.Weight == 0 || userInformationModel.Height == 0)
            {
                return(0);
            }

            result = userInformationModel.Weight / (userInformationModel.Height * userInformationModel.Height / 100 / 100);

            return(result);
        }
Exemplo n.º 35
0
        private bool CheckPassword(UserInformationModel oUser, string inputPassword)
        {
            //string hashedPass = GetHashPassword(oUser.User.NomorInduk, inputPassword, oUser.User.Salt);

            if (oUser.User.UserPassword.Equals(inputPassword))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 36
0
 public UserInformationVM()
 {
     Command = new UserInformationCommand(this);
     try
     {
         UserInformationM = new UserInformationModel();
         Users            = new ObservableCollection <User>(UserInformationM.GetUsers());
     }
     catch (Exception e)
     {
         (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString();
     }
 }
Exemplo n.º 37
0
        public ActionResult Index(UserInformationModel model)
        {
            CountCalories calories = new CountCalories();
            var           result   = calories.Calculate(model);

            //var bmi = Math.Round(calories.CalculateBMI(data.UserInformationModelRepo), 1);
            //var userBmiInfo = calories.interpreteBMI(bmi);
            //data.UserBmiModel.Bmi = bmi;
            //data.UserBmiModel.UserBmiInfo = userBmiInfo;

            //return View(data.UserBmiModel);
            ViewBag.Message = "Your contact page." + result;
            return(View());
        }
Exemplo n.º 38
0
        public AccountModel GetSignInUser(string userName, string password)
        {
            AccountModel oResult = new AccountModel();

            try
            {
                UserInformationModel oUserInfo = GetValidateUser(userName);
            }
            catch (Exception ex)
            {
                oResult.Exception = oException.Set(ex);
            }
            return(oResult);
        }
Exemplo n.º 39
0
        public bool CreateIssue(UserInformationModel<User> aUserCreating, Issue aIssueToCreate)
        {
            if (!ValidateIssue(aIssueToCreate) || !IssueDoesntExist(aIssueToCreate.Title)) {
                return false;
            }

            if (!AllowedToPerformAction(aUserCreating, SocialPermission.Post_Issue)) {
                return false;
            }

            Issue myIssue = theIssueRepository.CreateIssue(aIssueToCreate, aUserCreating.Details);
            theIssueRepository.MarkIssueAsUnreadForAuthor(myIssue.Id);
            return true;
        }
Exemplo n.º 40
0
        public JsonResult ChangePassword(UserInformationModel userInformation)
        {
            if (userInformation.Id <= 0)
            {
                userInformation.Id = LoginInformation.UserInformation.Id;
            }

            userInformation.SetUpdateProperties(LoginInformation.UserInformation.Id);
            _userInformationService.ChangePassword(userInformation);

            return(new JsonResult {
                Data = userInformation
            });
        }
Exemplo n.º 41
0
        /// <summary>
        /// Gets the UserCriteria of the specified user.
        /// If a user does not have any criteria,
        /// a default setting will be created for them based on their role.
        /// </summary>
        /// <param name="db">BridgeCareContext</param>
        /// <param name="userInformation">UserInformationModel</param>
        /// <returns>UserCriteriaModel</returns>
        public UserCriteriaModel GetOwnUserCriteria(BridgeCareContext db, UserInformationModel userInformation)
        {
            if (!db.UserCriteria.Any(criteria => criteria.USERNAME == userInformation.Name))
            {
                log.Info($"User '{userInformation.Name}' has logged in for the first time.");
                var newUserCriteria = new UserCriteriaEntity(GenerateDefaultUserCriteria(userInformation));
                db.UserCriteria.Add(newUserCriteria);
                db.SaveChanges();
                return(new UserCriteriaModel(newUserCriteria));
            }
            var userCriteria = db.UserCriteria.Single(criteria => criteria.USERNAME == userInformation.Name);

            return(new UserCriteriaModel(userCriteria));
        }
Exemplo n.º 42
0
 public static PersonalInformation ToUserInformation(this UserInformationModel model)
 {
     return(new PersonalInformation()
     {
         Id = model.Id,
         BirthDay = model.BirthDay,
         BloodStyle = model.BloodStyle,
         Favorates = model.Favorates,
         From = model.From,
         LiveIn = model.LiveIn,
         PersonnalDescription = model.PersonnalDescription,
         UserId = model.UserId,
         User = model.UserRelated
     });
 }
Exemplo n.º 43
0
    protected void Register_Click(object sender, EventArgs e)
    {
        var userStore = new UserStore <IdentityUser>();

        userStore.Context.Database.Connection.ConnectionString = "data source=PC-ITSIX61;initial catalog=Garage;integrated security=True;";
        var manager = new UserManager <IdentityUser>(userStore);

        var user = new IdentityUser();

        user.UserName = UserNameTB.Text;

        if (PasswordTB.Text.Equals(ConfirmPasswordTB.Text))
        {
            try
            {
                var result = manager.Create(user, PasswordTB.Text);

                if (result.Succeeded)
                {
                    var userInfo = new UserInformation();
                    userInfo.FirstName  = FirstName.Text;
                    userInfo.LastName   = LastName.Text;
                    userInfo.Address    = Address.Text;
                    userInfo.GUID       = user.Id;
                    userInfo.PostalCode = Convert.ToInt32(PostalCode.Text);
                    var userModel = new UserInformationModel();
                    userModel.InsertUserInformation(userInfo);
                    var autenticationManager = HttpContext.Current.GetOwinContext().Authentication;
                    var userIdentity         = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    autenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                    Response.Redirect("~/Index.aspx");
                }
                else
                {
                    Status.Text = result.Errors.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                Status.Text = ex.ToString();
            }
        }
        else
        {
            Status.Text = "Password and Confirm password must match";
        }
    }
Exemplo n.º 44
0
        public async Task <IHttpActionResult> RunSimulation([FromBody] SimulationModel model)
        {
            UserInformationModel userInformation = ESECSecurity.GetUserInformation(Request);
            var result = await Task.Factory.StartNew(() => SimulationRunMethods[userInformation.Role](model, userInformation));

            if (result.IsCompleted)
            {
                repo.SetSimulationLastRunDate(model.simulationId, db);
            }
            else
            {
                return(InternalServerError(new Exception(result.Result)));
            }

            return(Ok());
        }
Exemplo n.º 45
0
 public JsonResult Save([Bind(Include = "Id, UserTypeId, EmployeeId, RoleId, Username, Password, PasswordAgeLimit, IsPasswordChanged, IsLocked, WrongPasswordTryLimit, IsSuperAdmin, IsActive")] UserInformationModel userInformation, bool isInsert)
 {
     if (isInsert)
     {
         userInformation.SetCreateProperties(LoginInformation.UserInformation.Id);
         userInformation.Id = _userInformationService.Insert(userInformation);
     }
     else
     {
         userInformation.SetUpdateProperties(LoginInformation.UserInformation.Id);
         _userInformationService.Update(userInformation);
     }
     return(new JsonResult {
         Data = _userInformationService.GetById(userInformation.Id)
     });
 }
        public bool AddZipCodesForUser(UserInformationModel<User> anAdminUser, string anEmail, string aZipCodes)
        {
            if (!PermissionHelper<User>.AllowedToPerformAction(anAdminUser, SocialPermission.Create_Authority_Verification_Token)) {
                throw new PermissionDenied(ErrorKeys.PERMISSION_DENIED);
            }

            if (!IsValidZipCodes(anEmail, aZipCodes)) {
                return false;
            }

            IEnumerable<int> myZipCodes = aZipCodes.Split(',').Select(z => int.Parse(z.Trim()));

            theAuthenticationRepo.AddZipCodesForUser(anAdminUser.Details, anEmail, myZipCodes);

            return true;
        }
Exemplo n.º 47
0
        public bool CreateTextBook(UserInformationModel<User> aCreatingUser, TextBookViewModel aCreateTextBookModel)
        {
            if (!ValidTextBook(aCreateTextBookModel)) {
                return false;
            }

            Class myClass = theClassRepo.GetClass(aCreateTextBookModel.UniversityId, aCreateTextBookModel.ClassSubject, aCreateTextBookModel.ClassCourse);

            if(myClass == null) {
                theClassRepo.CreateClass(aCreatingUser.Details, aCreateTextBookModel.UniversityId, aCreateTextBookModel.ClassSubject, aCreateTextBookModel.ClassCourse, "No title");
            }

            string myBookImageName = string.Empty;

            if (aCreateTextBookModel.BookImage != null) {
                try {
                    myBookImageName = AWSPhotoHelper.TakeImageAndResizeAndUpload(aCreateTextBookModel.BookImage,
                        AWSHelper.GetClient(),
                        SiteConfiguration.TextbookPhotosBucket(),
                        aCreateTextBookModel.BookTitle.GetHashCode().ToString(),
                        TextBookConstants.BOOK_MAX_SIZE);
                } catch (Exception myException) {
                    throw new PhotoException("Unable to upload the textbook image.", myException);
                }
            }

            theTextBookRepo.CreateTextbook(aCreatingUser.Details,
                aCreateTextBookModel.UniversityId,
                aCreateTextBookModel.TextBookCondition,
                aCreateTextBookModel.BookTitle,
                aCreateTextBookModel.BookAuthor,
                myBookImageName,
                aCreateTextBookModel.ClassSubject,
                aCreateTextBookModel.ClassCourse,
                aCreateTextBookModel.Edition == null ? 0 : int.Parse(aCreateTextBookModel.Edition),
                double.Parse(aCreateTextBookModel.Price),
                string.IsNullOrEmpty(aCreateTextBookModel.Details) ? null : aCreateTextBookModel.Details,
                aCreateTextBookModel.ISBN);

            return true;
        }
Exemplo n.º 48
0
        public IEnumerable<Pair<Feature, bool>> GetFeatureSettingsForUser(UserInformationModel<User> aUser)
        {
            IEnumerable<Feature> myAllFeatures = theFeatureRepo.GetAllFeatures().OrderBy(f => f.ListOrder);
            IEnumerable<FeaturesEnabled> myAllFeaturesEnabled = theFeatureRepo.GetFeaturesEnabledForUser(aUser.Details);
            List<Pair<Feature, bool>> myFeatureAndSelection = new List<Pair<Feature, bool>>();

            foreach (Feature myFeature in myAllFeatures) {
                bool myEnabled = (from fe in myAllFeaturesEnabled
                                  where fe.FeatureName.Equals(myFeature.Name)
                                  select fe.Enabled)
                                  .DefaultIfEmpty(true)
                                  .FirstOrDefault();

                myFeatureAndSelection.Add(new Pair<Feature, bool>() {
                    First = myFeature,
                    Second = myEnabled
                });
            }

            return myFeatureAndSelection;
        }
Exemplo n.º 49
0
        public static bool IsAllowed(User aPrivacyUser, PrivacyAction aPrivacyAction, UserInformationModel<User> aViewingUser)
        {
            bool myIsAllowed = true;

            IEnumerable<string> myTargetUsersSettings =
                (from p in aPrivacyUser.UserPrivacySettings.ToList<UserPrivacySetting>()
                 select p.PrivacySettingName).ToList<string>();
            IEnumerable<Friend> myTargetUserFriends = aPrivacyUser.Friends.ToList<Friend>();

            if (aPrivacyAction == PrivacyAction.DisplayProfile) {
                if (aViewingUser == null || (aViewingUser != null && !FriendHelper.IsFriend(aPrivacyUser, aViewingUser.Details))) {
                    if (HasPrivacySetting(myTargetUsersSettings, SocialPrivacySetting.Display_Profile_To_Everyone)) {
                        myIsAllowed = true;
                    } else {
                        myIsAllowed = false;
                    }
                }
            }

            return myIsAllowed;
        }
Exemplo n.º 50
0
 public void MarkItemAsSeen(UserInformationModel<User> aUserInfo, int anItemId)
 {
     theSendItemsRepo.MarkItemAsSeen(aUserInfo.Details, anItemId);
 }
Exemplo n.º 51
0
 private static bool ShouldDisplayEditLink(UserInformationModel<User> aUserInformation, Issue anIssue)
 {
     return (PermissionHelper<User>.AllowedToPerformAction(aUserInformation, SocialPermission.Edit_Issue) && aUserInformation.Details.Id == anIssue.UserId)
         || PermissionHelper<User>.AllowedToPerformAction(aUserInformation, SocialPermission.Edit_Any_Issue);
 }
Exemplo n.º 52
0
        public SearchResultsModel GetClassSearchResults(UserInformationModel<User> aUserInformation, string aSearchString,
                                                        int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string aUniversityId)
        {
            IEnumerable<Class> myClasses = new List<Class>();
            string myUniversityId = "All";

            if (!aUniversityId.Equals("All")) {
                myUniversityId = aUniversityId;
                if (aSearchBy == SearchBy.Title) {
                    myClasses = theSearchRepository.GetClassByTitle(myUniversityId, aSearchString);
                } else if (aSearchBy == SearchBy.ClassCode) {
                    myClasses = theSearchRepository.GetClassByClassCode(myUniversityId, aSearchString);
                }
            } else {
                if (aSearchBy == SearchBy.Title) {
                    myClasses = theSearchRepository.GetClassByTitle(aSearchString);
                } else if (aSearchBy == SearchBy.ClassCode) {
                    myClasses = theSearchRepository.GetClassByClassCode(aSearchString);
                }
            }

            if (anOrderBy == OrderBy.Title) {
                myClasses = myClasses.OrderBy(r => r.Title);
            } else if (anOrderBy == OrderBy.ClassCode) {
                myClasses = myClasses.OrderBy(r => r.Subject + r.Course);
            }

            List<ISearchResult> mySearchResult = new List<ISearchResult>();

            mySearchResult.AddRange(myClasses.Select(r => new ClassSearchResult(r)));

            int myTotalResults = myClasses.Count<Class>();

            SearchResultsModel myModel =
                BuildSearchResultsModel(myUniversityId, mySearchResult, SearchFilter.CLASS, aPage, aSearchString,
                                        myTotalResults, SearchByForClass(), aSearchBy,
                                        OrderByForClass(), anOrderBy);
            return myModel;
        }
Exemplo n.º 53
0
        public SearchResultsModel GetTextBookSearchResults(UserInformationModel<User> aUserInformation, string aSearchString,
                                                   int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string aUniversityId)
        {
            IEnumerable<TextBook> myTextBooks = new List<TextBook>();
            string myUniversityId = "All";

            if (!aUniversityId.Equals("All")) {
                myUniversityId = aUniversityId;
                if (aSearchBy == SearchBy.Title) {
                    myTextBooks = theSearchRepository.GetTextBookByTitle(myUniversityId, aSearchString);
                } else if (aSearchBy == SearchBy.ClassCode) {
                    myTextBooks = theSearchRepository.GetTextBookByClassCode(myUniversityId, aSearchString);
                }
            } else {
                if (aSearchBy == SearchBy.Title) {
                    myTextBooks = theSearchRepository.GetTextBookByTitle(aSearchString);
                } else if (aSearchBy == SearchBy.ClassCode) {
                    myTextBooks = theSearchRepository.GetTextBookByClassCode(aSearchString);
                }
            }

            if (anOrderBy == OrderBy.Title) {
                myTextBooks = myTextBooks.OrderBy(r => r.BookTitle);
            } else if (anOrderBy == OrderBy.ClassCode) {
                myTextBooks = myTextBooks.OrderBy(r => r.ClassSubject + r.ClassCourse);
            } else if (anOrderBy == OrderBy.LowestPrice) {
                myTextBooks = myTextBooks.OrderBy(r => r.Price);
            } else if (anOrderBy == OrderBy.HighestPrice) {
                myTextBooks = myTextBooks.OrderByDescending(r => r.Price);
            }

            List<ISearchResult> mySearchResult = new List<ISearchResult>();

            mySearchResult.AddRange(myTextBooks.Select(r => new TextBookSearchResult(r) {
                UserInformationModel = aUserInformation
            }));

            int myTotalResults = myTextBooks.Count<TextBook>();

            SearchResultsModel myModel =
                BuildSearchResultsModel(myUniversityId, mySearchResult, SearchFilter.TEXTBOOK, aPage,
                                        aSearchString, myTotalResults, SearchByForTextbook(),
                                        aSearchBy, OrderByForTextbook(), anOrderBy);
            return myModel;
        }
Exemplo n.º 54
0
        public SearchResultsModel GetUserSearchResults(UserInformationModel<User> aUserInformation, string aSearchString,
                                                 int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string aUniversityId)
        {
            IEnumerable<User> myUsers = new List<User>();

            if (aSearchBy == SearchBy.Name) {
                if (aUserInformation == null) {
                    myUsers = theSearchRepository.GetUserByName(aSearchString);
                } else {
                    myUsers = theSearchRepository.GetUserByName(aUserInformation.UserId, aSearchString);
                }
            }

            if (anOrderBy == OrderBy.Name) {
                myUsers = myUsers.OrderBy(r => r.FirstName + " " + r.LastName);
            }

            List<ISearchResult> mySearchResult = new List<ISearchResult>();

            mySearchResult.AddRange(myUsers.Select(r => new UserSearchResult(r) {
                UserInformationModel = aUserInformation
            }));

            int myTotalResults = myUsers.Count<User>();

            SearchResultsModel myModel =
                BuildSearchResultsModel("All", mySearchResult, SearchFilter.USER, aPage,
                                        aSearchString, myTotalResults, SearchByForPeople(),
                                        aSearchBy, OrderByForPeople(), anOrderBy);
            return myModel;
        }
Exemplo n.º 55
0
        public SearchResultsModel MarketplaceSearchResults(UserInformationModel<User> aUserInformation, string aSearchString, int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string anItemType, string aUniversityId)
        {
            IEnumerable<MarketplaceItem> myItems = new List<MarketplaceItem>();
            string myUniversityId = "All";

            if (!aUniversityId.Equals("All")) {
                myUniversityId = aUniversityId;
                if (aSearchBy == SearchBy.Title) {
                    myItems = theMarketplaceSerivce.GetLatestItemsSellingInUniversityByItemAndTitle(myUniversityId, anItemType, aSearchString);
                }
            } else {
                if (aSearchBy == SearchBy.Title) {
                    myItems = theMarketplaceSerivce.GetLatestItemsSellingByTypeAndTitleForAnyUniversity(anItemType, aSearchString);
                }
            }

            if (anOrderBy == OrderBy.Title) {
                myItems = myItems.OrderBy(r => r.Title);
            } else if (anOrderBy == OrderBy.LowestPrice) {
                myItems = myItems.OrderBy(r => r.Price);
            } else if (anOrderBy == OrderBy.HighestPrice) {
                myItems = myItems.OrderByDescending(r => r.Price);
            } else if (anOrderBy == OrderBy.Newest) {
                myItems = myItems.OrderBy(r => r.DateTimeStamp);
            }

            List<ISearchResult> mySearchResult = new List<ISearchResult>();

            mySearchResult.AddRange(myItems.Select(r => new ItemSearchResult(r) {
                UserInformationModel = aUserInformation
            }));

            int myTotalResults = myItems.Count();

            SearchResultsModel myModel =
                BuildSearchResultsModel(myUniversityId, mySearchResult, (SearchFilter)Enum.Parse(typeof(SearchFilter), anItemType), aPage,
                                        aSearchString, myTotalResults, SearchByForItems(),
                                        aSearchBy, OrderByForItems(), anOrderBy);
            return myModel;
        }
 public void UpdateUserRegionSpecifics(UserInformationModel<User> aUserInfo, IEnumerable<Pair<AuthorityPosition, int>> aToAddAndUpdate, IEnumerable<Pair<AuthorityPosition, int>> aToRemove)
 {
     theAuthenticationRepo.UpdateUserRegionSpecifics(aUserInfo.Details, aToAddAndUpdate, aToRemove);
 }
Exemplo n.º 57
0
        private static string IssueInformationDiv(Issue anIssue, bool anAnonymous, UserInformationModel<User> aUserInfoModel, bool aHasStance, string anIssueInfoCssClass, string anEditAndStanceCssClass, string aReportCssClass, string anAgreeCssClass,
                                                 string aDisagreeCssClass, string anDeleteCssClass, string anEditCssClass, SiteSection aSiteSection, int aSourceId)
        {
            var myIssueInfoDiv = new TagBuilder("div");
            myIssueInfoDiv.AddCssClass(anIssueInfoCssClass);

            var myIssueInfoPadding = new TagBuilder("div");
            myIssueInfoPadding.AddCssClass("p-a10");
            myIssueInfoPadding.InnerHtml += SharedStyleHelper.InfoSpeakSpan("speak-lft");

            var myHeadTitle = new TagBuilder("h1");
            var myIssueLink = new TagBuilder("a");
            myIssueLink.MergeAttribute("href", LinkHelper.IssueUrl(anIssue.Title));
            myIssueLink.InnerHtml = anIssue.Title;
            myHeadTitle.InnerHtml += myIssueLink.ToString();

            string myName = NameHelper.FullName(anIssue.User);
            string myProfileLink = LinkHelper.Profile(anIssue.User);
            if (anAnonymous) {
                myName = HAVConstants.ANONYMOUS;
                myProfileLink = "#";
            }

            var myNameLink = new TagBuilder("a");
            myNameLink.AddCssClass("name-2");
            myNameLink.MergeAttribute("href", myProfileLink);
            myNameLink.InnerHtml = myName;

            var myLocationSpan = new TagBuilder("span");
            myLocationSpan.AddCssClass("loc c-white");
            myLocationSpan.InnerHtml = anIssue.City + ", " + anIssue.State;

            string myUserType = GetUserTypeForIssue(anIssue);
            var myIconSpan = new TagBuilder("span");
            myIconSpan.AddCssClass(myUserType);
            myIconSpan.MergeAttribute("title", myUserType);
            myIconSpan.InnerHtml = "&nbsp;";

            myIssueInfoPadding.InnerHtml += myHeadTitle.ToString();
            myIssueInfoPadding.InnerHtml += myNameLink.ToString();
            myIssueInfoPadding.InnerHtml += "&nbsp;";
            myIssueInfoPadding.InnerHtml += myLocationSpan.ToString();
            myIssueInfoPadding.InnerHtml += "&nbsp;";
            myIssueInfoPadding.InnerHtml += myIconSpan.ToString();
            myIssueInfoPadding.InnerHtml += new TagBuilder("br").ToString();
            myIssueInfoPadding.InnerHtml += PresentationHelper.ReplaceCarriageReturnWithBR(anIssue.Description);

            myIssueInfoPadding.InnerHtml += SharedStyleHelper.ClearDiv();

            var myEditAndStanceDiv = new TagBuilder("div");
            myEditAndStanceDiv.AddCssClass(anEditAndStanceCssClass);
            myEditAndStanceDiv.InnerHtml += SharedStyleHelper.StyledHtmlDiv(aReportCssClass, ComplaintHelper.IssueLink(anIssue.Id)).ToString();
            myEditAndStanceDiv.InnerHtml += DeleteDiv(aUserInfoModel, anIssue, anDeleteCssClass);
            myEditAndStanceDiv.InnerHtml += EditDiv(aUserInfoModel, anIssue, anEditCssClass);
            if (anAgreeCssClass != string.Empty) {
                myEditAndStanceDiv.InnerHtml += AgreeDiv(aUserInfoModel, anIssue, anAgreeCssClass, aSiteSection, aSourceId);
            }
            if (aDisagreeCssClass != string.Empty) {
                myEditAndStanceDiv.InnerHtml += DisagreeDiv(aUserInfoModel, anIssue, aDisagreeCssClass, aSiteSection, aSourceId);
            }
            myEditAndStanceDiv.InnerHtml += SharedStyleHelper.ClearDiv();

            myIssueInfoPadding.InnerHtml += myEditAndStanceDiv.ToString();

            myIssueInfoDiv.InnerHtml += myIssueInfoPadding.ToString();
            return myIssueInfoDiv.ToString();
        }
        private ActionResult RemoveMember(UserInformationModel<User> aUserInfo, int aGroupId, int aUserRemovingId, string aMessage)
        {
            try {
                bool myResult = theGroupService.RemoveGroupMember(aUserInfo, aUserRemovingId, aGroupId);

                if (myResult) {
                    TempData["Message"] += MessageHelper.SuccessMessage(aMessage);
                }
            } catch (Exception myException) {
                LogError(myException, REMOVE_ERROR);
                TempData["Message"] += MessageHelper.ErrorMessage(REMOVE_ERROR);
            }

            return RedirectToAction("Details", "Group", new { id = aGroupId });
        }
        public bool RequestTokenForAuthority(UserInformationModel<User> aRequestingUser, string anEmail, string anExtraInfo, string anAuthorityType, string anAuthorityPosition)
        {
            if (!PermissionHelper<User>.AllowedToPerformAction(aRequestingUser, SocialPermission.Create_Authority_Verification_Token)) {
                throw new CustomException(HAVConstants.NOT_ALLOWED);
            }

            if(!IsValidAuthorityInformation(anEmail, anAuthorityType, anAuthorityPosition)) {
                return false;
            }

            Random myRandom = new Random(DateTime.UtcNow.Millisecond);
            string myToken = myRandom.Next().ToString();
            string myHashedToken = HashHelper.DoHash(myToken);

            bool myExists = theAuthenticationRepo.TokenForEmailExists(anEmail, anAuthorityType, anAuthorityPosition);

            if (myExists) {
                theAuthenticationRepo.UpdateTokenForEmail(anEmail, myHashedToken, anAuthorityType, anAuthorityPosition);
            } else {
                theAuthenticationRepo.CreateTokenForEmail(aRequestingUser.Details, anEmail, myHashedToken, anAuthorityType, anAuthorityPosition);
            }

            SendTokenEmail(anEmail, anExtraInfo, myToken, anAuthorityType, anAuthorityPosition);

            return true;
        }
Exemplo n.º 60
0
 private static bool GetHasStance(Issue anIssue, UserInformationModel<User> aUserInfoModel)
 {
     bool myHasDisposition =  aUserInfoModel != null &&
                             (from s in anIssue.IssueDispositions
                              where s.UserId == aUserInfoModel.Details.Id
                              select s).Count<IssueDisposition>() > 0 ? true : false;
     return myHasDisposition;
 }