Наследование: System.Data.Objects.DataClasses.EntityObject
Пример #1
0
 public static void AssignUserList(User[] _objuser, int id)
 {
     foreach (var usr in _objuser)
     {
         AssignedToUser(usr.UserId, id);
     }
 }
Пример #2
0
        public SignupResponse SignupUser(SignupRaw raw)
        {
            // Convert from Raw --> Domain Entity
            var user = new Domain.User {
                Comments         = new List <Ref <Comment> >(),
                Email            = new Email(raw.Email),
                Movies           = new List <Ref <Domain.Movie> >(),
                Name             = new Name(raw.Name),
                Password         = new Password(raw.Password),
                Reviews          = new List <Ref <Domain.Review> >(),
                CreatedAt        = DateTime.Now,
                ProfileImagePath = new ImagePath()
            };

            // Check uniqueness of email
            if (!_userRepository.CheckEmailUniqueness(user.Email))
            {
                return(new SignupResponse(false, SignupResponseError.EmailUniqueness));
            }

            // Add user to context and save to DB
            var model = _userRepository.Add(user);

            _userRepository.SaveChanges();

            // create tokens
            var access  = _createToken(TokenType.Access, model.Id);
            var refresh = _createToken(TokenType.Refresh, model.Id);

            return(new SignupResponse(true, model.Id, access, refresh));
        }
        public TermEnvironment(ITermRepository termRepository, User user)
        {
            _termRepository = termRepository;
            _user = user;

            var pendingTerm = _termRepository.GetPendingTerm();

            CurrentTerm = pendingTerm ?? new Term(1);
        }
        public static Data.Entities.User Map(Domain.User dmUser)
        {
            Data.Entities.User deUser = new Entities.User();
            deUser.Id       = dmUser.id;
            deUser.Username = dmUser.username;
            deUser.Password = dmUser.password;

            return(deUser);
        }
Пример #5
0
        public void Logout(Domain.User user, IObserver client)
        {
            IObserver localClient = LoggedClients[user.Username];

            if (localClient == null)
            {
                throw new Exception("User " + user.Username + " is not logged in.");
            }
            LoggedClients.Remove(user.Username);
        }
Пример #6
0
        public void GetUserTeamsTest()
        {
            Data.Entities.HLContext _db  = new Data.Entities.HLContext();
            Data.TeamRepository     test = new Data.TeamRepository(_db);

            Domain.User        user     = new Domain.User("username1", "password1");
            List <Domain.Team> teamlist = test.GetUserTeams(user);

            Assert.AreNotEqual(teamlist, null);
        }
        /// <summary>
        /// Creates a new Password Reset Ticket for the specified user.
        /// </summary>
        public static void RequestTicket(User user)
        {
            var service = new PasswordResetService(user);

            using (var scope = Database.CreateTransactionScope())
            {
                service.CreateTicket();
                service.SendEmail();
                scope.Complete();
            }
        }
        //public IActionResult Login([FromBody] Domain.User user)
        public IActionResult Login([FromBody] Domain.User user)
        {
            bool success = _UserRepository.validatelogin(user.username, user.password);

            if (success)
            {
                Domain.User realUser = _UserRepository.GetUserByUsername(user.username);
                return(Ok(new { user = realUser.id }));
            }
            return(Unauthorized(new { message = "Username doesn't exist or password is incorrect." }));
        }
Пример #9
0
        public void TearDown()
        {
            _userRoleLink = _userRoleLinkRepository.Get(_userRoleLink.Id);
                _userRoleLinkRepository.Delete(_userRoleLink);
            _user = _userRepository.Get(_user.Id);
            _userRepository.Delete(_user);

            _role = _roleRepository.Get(_role.Id);
                _roleRepository.Delete(_role);
            _burrow.CloseWorkSpace();
        }
        public static InternalUser Create(Guid id, User user)
        {
            var internalUser = ObjectInstantiator<InternalUser>.CreateNew();

            ObjectInstantiator<InternalUser>.SetProperty(x => x.Id, id, internalUser);
            ObjectInstantiator<InternalUser>.SetProperty(x => x.User, user, internalUser);
            ObjectInstantiator<InternalUser>.SetProperty(x => x.UserId, user.Id, internalUser);

            ObjectInstantiator<InternalUser>.SetProperty(x => x.CompetentAuthority, UKCompetentAuthority.England, internalUser);

            return internalUser;
        }
Пример #11
0
 public static Data.Models.User ToEntity(this Domain.User domain)
 {
     return(new Data.Models.User()
     {
         Id = domain.Id,
         Username = domain.Username,
         Password = domain.Password,
         Added = domain.Added,
         CouponUser = domain.CouponUser.ToEntityList(),
         Request = domain.Request.ToEntityList()
     });
 }
        public bool DeleteUser(Domain.User user)
        {
            bool success = false;

            Data.Entities.User x = _db.User.Where(a => a.Username.Equals(user.username)).FirstOrDefault();
            if (x != null)
            {
                _db.User.Remove(x);
                success = true;
            }
            return(success);
        }
Пример #13
0
 /// <summary>
 /// Setups the user data.
 /// </summary>
 /// <returns>The Users</returns>
 public static User SetupUserData()
 {
     var user = new User();
     user.FirstName = "R";
     user.LastName = "Della";
     user.PersonId = "2";
     user.Stateroom = "701";
     user.UserUId = "484516";
     user.ReservationId = "12";
     user.MiddleName = "M";
     user.ImageAddress = "http://dc-mage.dhc.chf/image?hkjdksdhf=87634kjhg";
     return user;
 }
Пример #14
0
 public static void Send(Beacon beacon, User user, User creator, string subject, string text)
 {
     if (creator.ContactBySMS && !string.IsNullOrWhiteSpace(creator.PhoneNumber))
     {
         var twilio = new TwilioHelper();
             twilio.SendSMS(creator.PhoneNumber, text);
     }
     else if (creator.ContactByEmail && !string.IsNullOrWhiteSpace(creator.Email))
     {
         var sendgrid = new SendGridHelper();
             sendgrid.Send(creator.Email, subject, text);
     }
 }
Пример #15
0
        public ModelUser AsignDomainUser(Domain.User user)
        {
            ModelUser muser = new ModelUser();

            muser.Password  = user.Password;
            muser.UserName  = user.UserName;
            muser.UserID    = user.UserID;
            muser.Name      = user.Name;
            muser.Surname   = user.Surname;
            muser.Email     = user.Email;
            muser.BirthDate = user.BirthDate;

            return(muser);
        }
        public bool AddUser(Domain.User user)
        {
            bool check = false;

            Data.Entities.User x = _db.User.Where(a => a.Username.Equals(user.username)).FirstOrDefault();
            if (x != null)
            {
                check = false;
            }
            else
            {
                _db.User.Add(Mapper.Map(user));
                check = true;
            }
            return(check);
        }
Пример #17
0
        public bool login(Thrift.User user, int port)
        {
            Domain.User usr = userRepo.FindOne(user.Id);
            if (usr == null || !usr.password.Equals(user.Password))
            {
                return(false);
            }
            TTransport transport = new TSocket("localhost", port);

            transport.Open();
            TProtocol protocol = new TBinaryProtocol(transport);

            ThriftObserver.Client client = new ThriftObserver.Client(protocol);
            observers.TryAdd(port, client);
            return(true);
        }
Пример #18
0
 public void Login(Domain.User inputUser, IObserver client)
 {
     Domain.User user = UserRepo.GetByUsername(inputUser.Username);
     if (user == null)
     {
         throw new Exception("Authentication failed.");
     }
     if (user.Password != inputUser.Password)
     {
         throw new Exception("Authentication failed.");
     }
     if (LoggedClients.ContainsKey(user.Username))
     {
         throw new Exception("User already logged in.");
     }
     LoggedClients[user.Username] = client;
 }
Пример #19
0
        //DES des = new DES();

        // POST: api/User
        public User Post([FromBody] Object value)
        {
            User user = new Domain.User();

            //string jsonString = des.Decrypt(value.ToString());
            user = JsonConvert.DeserializeObject <User>(value.ToString());


            if (!userBusiness.verifyEmail(user.email))
            {
                return(this.userBusiness.SignUp(user));
            }
            else
            {
                return(null);
            }
        }
Пример #20
0
        public static User GetUserDetails(string username)
        {
            User _objUser = new User();
            using (var context = new PrincipalContext(ContextType.Domain, "erccollections.com"))
            {
                var usr = UserPrincipal.FindByIdentity(context, username);
                if (usr != null)
                {

                    _objUser.DisplayName = usr.DisplayName;
                    _objUser.UserName = username;
                    _objUser.Email = usr.EmailAddress;
                    _objUser.UserRole = "user";
                }
            }
            return _objUser;
        }
        public static AccountSummaryViewModel Load(User user)
        {
            var vm = new AccountSummaryViewModel();

            vm.Name = user.Name;
            vm.EmailAddress = user.EmailAddress;
            vm.PhoneNumber = user.PhoneNumber;

            vm.Teams = new List<string>();

            foreach (ClubTeam team in user.Teams)
            {
                vm.Teams.Add(team.Name);
            }

            return vm;
        }
Пример #22
0
        public void CreateUser()
        {
            _fixture = new Fixture();

            _role = new Role {Name = _fixture.Create<string>()};

            _roleRepository.Save(_role);
            _user = new User {Name = _fixture.Create<string>()};

            _userRepository.Save(_user);

            _userRoleLink = new UserRoleLink(_user,_role);
            _userRoleLinkRepository.Save(_userRoleLink);
               _burrow.CloseWorkSpace();
            _burrow.InitWorkSpace();

            Assert.AreEqual(_userRepository.FindByRoleId(_role.Id).ToList().First(), _user);
        }
        public IActionResult Register([FromBody] Domain.User user)
        {
            bool validated = _UserRepository.validateusername(user.username);

            if (validated)
            {
                return(BadRequest(new { message = "Username already exists." }));
            }

            _UserRepository.AddUser(user);
            _UserRepository.Save();
            if (_UserRepository.validateusername(user.username) == false)
            {
                return(StatusCode(500));
            }

            return(Created("api/User/Register", _UserRepository.GetUserByUsername(user.username).id));
        }
Пример #24
0
        public void addUserTest()
        {
            Event target = new Event(); // TODO: Initialize to an appropriate value
            User user = new User(); // TODO: Initialize to an appropriate value

            // Initially empty
            Assert.AreEqual(0,target.userList.Length);

            // Add one
            target.addUser(user);

            // Now +1
            Assert.AreEqual(1, target.userList.Length);

            // The inserted user now exists
            Assert.IsTrue(target.userList[1].Equals(user));

            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Пример #25
0
        private Domain.User GetDbUser(string messengerUserId)
        {
            var dbUser = users.FirstOrDefault(user => user.MessengerUserId == messengerUserId);

            if (dbUser != null)
            {
                return(dbUser);
            }

            dbUser = new Domain.User
            {
                MessengerUserId = messengerUserId, BankAccountToYnabAccounts = new List <BankAccountToYnabAccount>(), DefaultYnabAccount = new YnabAccount(), Access = new YnabAccess()
            };
            dbContext.Add(dbUser);

            dbContext.SaveChanges();

            return(dbUser);
        }
Пример #26
0
        public Domain.User GetUserDetails(string UserName, string Password)
        {
            Domain.User user = new Domain.User();

            try
            {
                using (SqlConnection con = new SqlConnection(this.ConnectionString))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("sp_GetUserDetails", con);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserName", UserName);
                    cmd.Parameters.AddWithValue("@Password", Password);

                    SqlDataReader sdr = cmd.ExecuteReader();

                    while (sdr.Read())
                    {
                        user.ID         = Int32.Parse(sdr["ID"].ToString());
                        user.UserName   = sdr["Name"].ToString();
                        user.Password   = sdr["Password"].ToString();
                        user.IsLoggedIn = Boolean.Parse(sdr["IsLoggedIn"].ToString());
                    }
                }
            }
            catch (FormatException fe)
            {
                throw fe;
            }
            catch (SqlException se)
            {
                throw se;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(user);
        }
Пример #27
0
 public static User Login(string userName, string password)
 {
     using (var context = new PrincipalContext(ContextType.Domain, "erccollections.com"))
     {
         var usr = UserPrincipal.FindByIdentity(context, userName);
         if (usr != null)
         {
             var verified = context.ValidateCredentials(userName, password);
             if (verified)
             {
                 using (var conn = new SqlConnection(ConnectionString))
                 {
                     conn.Open();
                     var user =
                         conn.Query<User>(
                             "select * from [collect2000].[ERCTasks].[Users] WHERE UserName = @userName",
                             new { userName = userName }).FirstOrDefault();
                     if (user == null)
                     {
                         var userId = conn.ExecuteScalar<int>(
                             "INSERT INTO [collect2000].[ERCTasks].[Users] (UserName, DisplayName, Email) VALUES (@userName, @dispName, @email); SELECT SCOPE_IDENTITY();",
                             new { userName = userName, dispName = usr.DisplayName, email = usr.EmailAddress });
                         user = new User()
                         {
                             DisplayName = usr.DisplayName,
                             UserName = userName,
                             UserRole = "user",
                             UserId = userId,
                             Email = usr.EmailAddress
                         };
                     }
                     return user;
                 }
             }
         }
     }
     return null;
 }
Пример #28
0
        public void GetByTeamNameTest()
        {
            Data.Entities.HLContext _db      = new Data.Entities.HLContext();
            Data.TeamRepository     test     = new Data.TeamRepository(_db);
            Data.UserRepository     usertest = new Data.UserRepository(_db);
            bool success;



            Domain.Team miteam = new Domain.Team();
            miteam.teamname = "grisaia";
            Domain.User user1 = new Domain.User("username1", "password1");

            /*
             * //get team id for next query
             * Data.Entities.Team ii = _db.Team.Where(ss => ss.Teamname.Equals("grisaia")).FirstOrDefault();
             * //first remove all userteams associated with this team
             * IEnumerable<Data.Entities.UserTeam> grisaiausers = _db.UserTeam.Where(a => a.Teamid == ii.Id);
             * _db.SaveChanges();
             * if (grisaiausers.GetEnumerator()!=null)
             * {
             *  foreach (var item in grisaiausers)
             *  {
             *      _db.UserTeam.Remove(item);
             *
             *  }
             *  _db.SaveChanges();
             *
             *
             * }
             */

            //remove user from db if it exist
            success = usertest.DeleteUser(user1);
            usertest.Save();
            //add user to the database;
            success = usertest.AddUser(user1);
            usertest.Save();
            if (!success)
            {
                Assert.Fail();
            }
            _db.SaveChanges();

            //obtain the user from the database so it has the userID
            var x = _db.User.Where(a => a.Username.Equals(user1.username)).FirstOrDefault();

            Domain.User user1withID = Mapper.Map(x);

            miteam.Userlist.Add(user1withID);
            miteam.Roles.Add(true);

            //remove team from db if it exist
            success = test.DeleteTeam(miteam);
            //add team to database
            success = test.AddTeam(miteam);



            //obtain the team from the database so it has a teamID
            var y = _db.Team.Where(gg => gg.Teamname.Equals(miteam.teamname)).FirstOrDefault();

            Domain.Team miteamwithID = Mapper.Map(y);
            miteamwithID.Userlist.Add(user1withID);
            miteamwithID.Roles.Add(true);

            //create the userteam entity from the above.
            IEnumerable <Data.Entities.UserTeam> userteam = Mapper.Map(miteam).UserTeam;



            Domain.Team newteam = test.GetByTeamName("grisaia");



            Assert.AreEqual(newteam.Userlist.Count, miteam.Userlist.Count);
            Assert.AreEqual(newteam.Roles.Count, miteam.Roles.Count);

            //remove stuffs from database.


            //delete the userteam enetities in the database if they are already there
            foreach (var item in userteam)
            {
                var uu = _db.UserTeam.Where(gg => gg.Id == item.Id).FirstOrDefault();
                if (uu != null)
                {
                    _db.UserTeam.Remove(item);
                    _db.SaveChanges();
                }
            }

            success = test.DeleteTeam(miteamwithID);
            success = usertest.DeleteUser(user1withID);
        }
Пример #29
0
        public void UpdateTeamTest()
        {
            Data.Entities.HLContext _db      = new Data.Entities.HLContext();
            Data.TeamRepository     test     = new Data.TeamRepository(_db);
            Data.UserRepository     usertest = new Data.UserRepository(_db);

            //preliminary stuff to clean database in case this stuff is already in there
            //first see if the team used in this test is in the DB
            Data.Entities.Team isthisteamhere = _db.Team.Where(o => o.Teamname.Equals("testteamname")).FirstOrDefault();
            if (isthisteamhere != null)
            {
                //obtain the primary key for this team
                int primarykey = isthisteamhere.Id;
                //remove the userteam(s) associated with this team
                IEnumerable <UserTeam> ww = _db.UserTeam.Where(mm => mm.Teamid == primarykey);
                foreach (var item in ww)
                {
                    _db.UserTeam.Remove(item);
                }
                _db.SaveChanges();
                //now we can remove the team
                _db.Team.Remove(isthisteamhere);
                _db.SaveChanges();
            }

            //now we can remove our user1 and 2 if they exist
            Data.Entities.User isthisuserhere = _db.User.Where(p => p.Username.Equals("username1")).FirstOrDefault();
            if (isthisuserhere != null)
            {
                _db.User.Remove(isthisuserhere);
                _db.SaveChanges();
            }
            Data.Entities.User isthisuserhere2 = _db.User.Where(p => p.Username.Equals("username2")).FirstOrDefault();
            if (isthisuserhere2 != null)
            {
                _db.User.Remove(isthisuserhere2);
                _db.SaveChanges();
            }



            bool what;    //random bool to hold data about success of methods.
            bool success; //initialize boolean for asserts

            //first case, we pass the method a faulty team check for null case and count case.
            Domain.Team team = new Domain.Team();
            success = test.UpdateTeam(team);
            Assert.AreEqual(success, false);



            //second test case for we have an empty team in the database and it is updated to contain a team.
            team.teamname = "testteamname";

            Domain.User user = new Domain.User("username1", "password1");

            //need to add user to db and pull it to get a stupid id
            success = usertest.DeleteUser(user);
            usertest.Save();
            //add user to the database;
            success = usertest.AddUser(user);
            usertest.Save();
            if (!success)
            {
                Assert.Fail();
            }
            _db.SaveChanges();

            //obtain the user from the database so it has the userID
            var x = _db.User.Where(a => a.Username.Equals(user.username)).FirstOrDefault();

            Domain.User user1withID = Mapper.Map(x);

            team.Roles.Add(true);
            team.Userlist.Add(user1withID);

            what = test.DeleteTeam(team);
            what = test.AddTeam(team);

            //now I will add another user to the team and see if it updates.
            Domain.User user2 = new Domain.User("username2", "password2");
            usertest.AddUser(user2);
            usertest.Save();
            var xx = _db.User.Where(a => a.Username.Equals(user2.username)).FirstOrDefault();

            Domain.User user2withID = Mapper.Map(xx);
            team.AddMember(user2withID);

            success = test.UpdateTeam(team);
            Assert.AreEqual(success, true);
            //keep database clean and undo the things i put in it
            //first remove the userteams
            //preliminary stuff to clean database in case this stuff is already in there
            //first see if the team used in this test is in the DB
            Data.Entities.Team isthisteamhere3 = _db.Team.Where(o => o.Teamname.Equals("testteamname")).FirstOrDefault();
            if (isthisteamhere3 != null)
            {
                //obtain the primary key for this team
                int primarykey = isthisteamhere3.Id;
                //remove the userteam(s) associated with this team
                IEnumerable <UserTeam> ww = _db.UserTeam.Where(mm => mm.Teamid == primarykey);
                foreach (var item in ww)
                {
                    _db.UserTeam.Remove(item);
                }
                _db.SaveChanges();
                //now we can remove the team
                _db.Team.Remove(isthisteamhere3);
                _db.SaveChanges();
            }

            //now we can remove our user1 and 2 if they exist
            Data.Entities.User isthisuserhere3 = _db.User.Where(p => p.Username.Equals("username1")).FirstOrDefault();
            if (isthisuserhere3 != null)
            {
                _db.User.Remove(isthisuserhere3);
                _db.SaveChanges();
            }
            Data.Entities.User isthisuserhere4 = _db.User.Where(p => p.Username.Equals("username2")).FirstOrDefault();
            if (isthisuserhere4 != null)
            {
                _db.User.Remove(isthisuserhere4);
                _db.SaveChanges();
            }
        }
Пример #30
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.UserName, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    var newUser = new User { UserName = model.UserName, EMail = model.Email };
                    _userRepository.Add(newUser);
                    _userRepository.Save();

                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    return RedirectToAction("Feed", "Users");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public Save(Model.User user)
 {
     Domain.User dUser = Mapper.Map(user);
     repository.Save(dUser);
 }
 public void SetUp()
 {
     mediator = new Mock<IMediator>();
     user = new Parent("Mike", "*****@*****.**", "xxx");
 }
 /// <summary>
 /// Sends an email to the specified user using this template and the merge data provided.
 /// </summary>
 public void Send(User toUser, object mergeData, Action<EmailQueueItem> customise = null)
 {
     Send(toUser.Email, mergeData, customise);
 }
Пример #34
0
        public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, AccountLinkingInfoViewModel accountLinkingModel, string returnUrl)
        {
            if (this.User.Identity.IsAuthenticated)
            {
                return this.RedirectToAction("Index", "Manage");
            }

            if (this.ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await this.AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return this.View("ExternalLoginFailure");
                }

                User user;
                IdentityResult result = null;
                bool isSuccessful = true;

                if (accountLinkingModel.AuskfId > 0)
                {
                    //Find user by auskf id if it is provided
                    using (var context = new DataContext())
                    {
                        user = (from x in context.Users.Include(u => u.Profile)
                                where x.AuskfId == accountLinkingModel.AuskfId
                                select x).FirstOrDefault();
                        user.UserName = model.Email;
                    }
                }
                else
                {
                    using (var context = new DataContext())
                    {
                        int auskfId = (from x in context.Users
                                       select x.AuskfId).Max();
                        // TODO This should not be created here, move to factory
                        user = new User {
                            Profile = new UserProfile(),
                            AuskfId = auskfId
                        };
                    }
                }

                user.UserName = model.Email;
                user.PasswordLastChangedDate = DateTime.Now;
                user.MaximumDaysBetweenPasswordChange = 180;
                user.Email = model.Email;
                user.JoinedDate = DateTime.Now; 
                user.LastLogin = DateTime.Now;
                user.Active = true;

                if (accountLinkingModel.AuskfId == 0)
                {
                    result = await this.UserManager.CreateAsync(user);
                    isSuccessful = result.Succeeded;
                }

                if (isSuccessful)
                {
                    result = await this.UserManager.AddLoginAsync(user.Id, info.Login);
                    if (result.Succeeded)
                    {
                        await this.SignInManager.SignInAsync(user, false, false);
                        return this.RedirectToLocal(returnUrl);
                    }
                }

                this.AddErrors(result);
            }

            this.ViewBag.ReturnUrl = returnUrl;
            return this.View(model);
        }
Пример #35
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
Пример #36
0
    public Save(VMUser user)
    {
        DUser dUser = Mapper.Map(user);

        repository.Save(dUser);
    }
Пример #37
0
        public void sendInvitationsTest()
        {
            Event target = new Event();
            User user = new User();

            target.addUser(user);

            target.sendInvitations();

            Assert.IsTrue(user.Calendar.Invitations.Contains(target.getInvitation()));
        }
Пример #38
0
        public User findUser(string userName)
        {
            db = new LinqToSQLDatacontext(connectionString);

            user u = db.users.FirstOrDefault(e => e.name == userName);

            User foundUser = new User(u.name, u.password);

            return foundUser;
        }
 private static bool MatchPassword(User user, string password)
 {
     return user.Password == GetPasswordHash(user.HashId, password);
 }
Пример #40
0
 /// <summary>
 /// Method to add a user to the 
 /// </summary>
 /// <param name="user">The user to add</param>
 public void addUser(User user)
 {
     throw new NotImplementedException();
 }
Пример #41
0
 public bool CompareUsingId(User user)
 {
     return(Id == user.Id);
 }
Пример #42
0
        public void AddAndRemoveTeamTest()
        {
            Data.Entities.HLContext _db      = new Data.Entities.HLContext();
            Data.TeamRepository     test     = new Data.TeamRepository(_db);
            Data.UserRepository     usertest = new Data.UserRepository(_db);

            bool success; //variable to determine if a team was added or removed successfully.

            Domain.Team x = new Domain.Team();
            x.teamname = "XXstarstrikersXX1113452435x4";
            success    = test.DeleteTeam(x);
            _db.SaveChanges();
            success = test.AddTeam(x);
            _db.SaveChanges();
            //assert that the team was added to the database
            Assert.AreEqual(success, true);

            success = test.AddTeam(x);
            _db.SaveChanges();
            //assert that the team was not added to the database because it already exists
            Assert.AreEqual(success, false);

            //assert that the team was successfuly deleted from the database
            success = test.DeleteTeam(x);
            _db.SaveChanges();
            Assert.AreEqual(success, true);

            //assert that the team was not deleted from the database because it did not exist
            success = test.DeleteTeam(x);
            _db.SaveChanges();
            Assert.AreEqual(success, false);

            //assert that the propery userteam table was added to the database
            Domain.User anewuser = new Domain.User("newuser89", "newpassword89");
            //delete the user from DB incase it exist
            success = usertest.DeleteUser(anewuser);
            if (success)
            {
                usertest.Save();
            }
            //add the user to the DB
            success = usertest.AddUser(anewuser);
            if (success)
            {
                usertest.Save();
            }

            //pull the user from the database
            Domain.User anewuserwithID = usertest.GetUserByUsername("newuser89");
            //add the user to the team
            x.AddMember(anewuserwithID);
            //add the team to the DB
            success = test.DeleteTeam(x);
            _db.SaveChanges();
            success = test.AddTeam(x);
            _db.SaveChanges();

            //now check that a usertable was created properly for the team
            Data.Entities.UserTeam userteam = _db.UserTeam.Where(jj => jj.Userid == anewuserwithID.id).FirstOrDefault();

            Assert.AreEqual(userteam.Userid, anewuserwithID.id);

            //now remove the team from the db
            success = test.DeleteTeam(x);

            Data.Entities.UserTeam deleted = _db.UserTeam.Where(jj => jj.Userid == anewuserwithID.id).FirstOrDefault();
            //check that the userteam was deleted
            Assert.AreEqual(deleted, null);

            //delete the user from the DB to keep it clean
            usertest.DeleteUser(anewuserwithID);
            usertest.Save();
        }
Пример #43
0
 public static void Update(User User)
 {
     DbCommand cmd = db.GetStoredProcCommand("dbo.UpdateUser");
     db.AddInParameter(cmd, "@FirstName", DbType.String, User.FirstName);
     db.AddInParameter(cmd, "@LastName", DbType.String, User.LastName);
     db.AddInParameter(cmd, "@Email", DbType.String, User.Email);
     db.AddInParameter(cmd, "@Password", DbType.String, User.Password);
     db.AddInParameter(cmd, "@UserId", DbType.Int32, User.Id);
     db.ExecuteNonQuery(cmd);
 }
 PasswordResetService(User user)
 {
     this.User = user;
 }
        private static SocialData ParceTweetsIntoObject(string jsonData)
        {
            SocialData socialData = new SocialData();
            Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonData);

            foreach (var item in dictionary)
            {
                if (_tweetLookupDictionary.ContainsKey(item.Key))
                {
                    object propValu = item.Value;
                    if (propValu != null)
                        ReflectionUtils.SetProperty(socialData, _tweetLookupDictionary[item.Key], propValu.ToString());
                }
            }
            User user = new User();
            if (dictionary.ContainsKey("user"))
            {
                object userData = dictionary["user"];
                if (userData != null)
                {
                    Dictionary<string, object> userDic = JsonConvert.DeserializeObject<Dictionary<string, object>>(userData.ToString());
                    foreach (var item in userDic)
                    {
                        if (_userLookupDictionary.ContainsKey(item.Key))
                        {
                            object propValu = item.Value;
                            if (propValu != null)
                                ReflectionUtils.SetProperty(user, _userLookupDictionary[item.Key], propValu.ToString());
                        }
                    }
                }
                else
                    return null;
            }

            socialData.User = user;
            return socialData;
        }
 public TermEnvironmentDecorator(ITermRepository termRepository, User user)
     : base(termRepository, user)
 {
 }
Пример #47
0
 public static void Delete(User User)
 {
     DbCommand cmd = db.GetStoredProcCommand("dbo.DeleteUser");
     db.AddInParameter(cmd, "@UserId", DbType.Int32, User.Id);
 }
Пример #48
0
 public static void Insert(User User)
 {
     DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO Users (Email, Password, FirstName, LastName, BusinessId) VALUES ('{0}', '{1}', '{2}', '{3}', {4});", User.Email, User.Password, User.FirstName, User.LastName, User.BusinessId));
     db.ExecuteNonQuery(cmd);
 }
Пример #49
0
 public bool CompareUsingEmailAndPassword(User user)
 {
     return(Email == user.Email && Password == user.Password);
 }
Пример #50
0
 public MongoDbUser()
 {
     _user = new User();
     Todos = new List<ObjectId>();
 }
Пример #51
0
        public async Task<ActionResult> Register(RegisterViewModel model, AccountLinkingInfoViewModel accountLinkingModel)
        {
            try
            {
                if (this.ModelState.IsValid)
                {
                    User user;
                    IdentityResult result;

                    if (accountLinkingModel.AuskfId > 0)
                    {
                        using (var context = new DataContext())
                        {
                            user = (from x in context.Users.Include(u => u.Profile)
                                    where x.AuskfId == accountLinkingModel.AuskfId
                                    select x).FirstOrDefault();
                        }
                        user.UserName = model.Email;
                        user.Email = model.Email;
                        user.Password = model.Password;
                        result = await this.UserManager.UpdateAsync(user);
                    }
                    else
                    {
                        user = new User
                        {
                            UserName = model.Email,
                            Email = model.Email
                        };
                        result = await this.UserManager.CreateAsync(user, model.Password);
                    }

                    if (result.Succeeded)
                    {
                        var code = await this.UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                        var url = this.Request.Url;
                        if (url != null)
                        {
                            var callbackUrl = this.Url.Action("ConfirmEmail", "Account", new
                            {
                                userId = user.Id,
                                code
                            }, url.Scheme);

                            await this.UserManager.SendEmailAsync(user.Id, "Confirm your account",
                                    "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
                            this.ViewBag.Link = callbackUrl;
                        }
                        return this.View("DisplayEmail");
                    }

                    this.AddErrors(result);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                        eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Value: \"{1}\", Error: \"{2}\"",
                            ve.PropertyName,
                            eve.Entry.CurrentValues.GetValue<object>(ve.PropertyName),
                            ve.ErrorMessage);
                    }
                }
                throw;
            }


            // If we got this far, something failed, redisplay form
            return this.View(model);
        }
Пример #52
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="applicationId">Initial value of the ApplicationId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="loweredUserName">Initial value of the LoweredUserName property.</param>
 /// <param name="isAnonymous">Initial value of the IsAnonymous property.</param>
 /// <param name="lastActivityDate">Initial value of the LastActivityDate property.</param>
 public static User CreateUser(global::System.Guid applicationId, global::System.Guid userId, global::System.String userName, global::System.String loweredUserName, global::System.Boolean isAnonymous, global::System.DateTime lastActivityDate)
 {
     User user = new User();
     user.ApplicationId = applicationId;
     user.UserId = userId;
     user.UserName = userName;
     user.LoweredUserName = loweredUserName;
     user.IsAnonymous = isAnonymous;
     user.LastActivityDate = lastActivityDate;
     return user;
 }
Пример #53
0
 public void login(Domain.User user, int port)
 {
 }