예제 #1
0
 public void Setup()
 {
     CreateResponses();
     _userRepository = new Mock<IUserRepository>();
     _memberShipService = new Mock<IMemeberShipService>();
     _user = new User
     {
         Name = "test",
         Password = "******",
         DeviceRegistrations = new Collection<Device>
                 {
                     new Device
                         {
                             KeyHandle = _deviceRegistration.KeyHandle,
                             PublicKey = _deviceRegistration.PublicKey,
                             AttestationCert = _deviceRegistration.AttestationCert,
                             Counter = (int) _deviceRegistration.Counter
                         }
                 },
         AuthenticationRequest = new List<AuthenticationRequest>
             {
                 new AuthenticationRequest
                 {
                     AppId = "test",
                     KeyHandle = _authenticateResponse.KeyHandle,
                     Challenge = _authenticateResponse.GetClientData().Challenge
                 }
             }
     };
 }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public long CreateUser(DataModels.User user)
        {
            using (var db = new PapersDB())
            {
                long st = db.GetTable <DataModels.User>().Insert(() => new DataModels.User {
                    Name1    = user.Name1,
                    Name2    = user.Name2,
                    Name3    = user.Name3,
                    Login    = user.Login,
                    AccessId = user.AccessId,
                    OtdId    = user.OtdId,
                    Ps       = 0,
                    Password = user.Password
                });

                return(db.Users.Where(w => w.Login == user.Login).FirstOrDefault().UserId);

                //db.GetTable<Cell>().Insert(() => new Cell {
                //    Advantage = "",
                //    Artlst = "214234",
                //    CompensationSp = "sdvf"

                //    db.Users.Where(w => w.UserId == user.UserId)
                //        .Set(p => p.AccessId, user.AccessId)
                //        //.Set(p => p.accessid18EBB, user.accessid18EBB)
                //        .Set(p => p.Login, user.Login)
                //        .Set(p => p.Name1, user.Name1)
                //        .Set(p => p.Name2, user.Name2)
                //        .Set(p => p.Name3, user.Name3)
                //        .Set(p => p.OtdId, user.OtdId)
                //        //.Set(p => p.otdid17F790F, user.otdid17F790F)
                //        .Set(p => p.UserId, user.UserId).Update();
                //}
            }
        }
        public void Setup()
        {
            service = new Mock<ITodoService>();
            _user = new User();
            _user.Name = "Alice";
            _user.EMail = "*****@*****.**";
            _user.Todos = new List<Todo>();

            _user.Todos.Add(new Todo { Description = "Get lunch", Priority = 1, DoBy = DateTime.Now });
            _user.Todos.Add(new Todo { Description = "Get tea", Priority = 1, DoBy = DateTime.Now });
            _user.Todos.Add(new Todo { Description = "Get dinner", Priority = 1, DoBy = DateTime.Now });
        }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="user"></param>
 public void SetUser(DataModels.User user)
 {
     using (var db = new PapersDB())
     {
         db.Users.Where(w => w.UserId == user.UserId)
         //.Set(p => p.AccessId, user.AccessId)
         //.Set(p => p.accessid18EBB, user.accessid18EBB)
         .Set(p => p.Login, user.Login)
         .Set(p => p.Name1, user.Name1)
         .Set(p => p.Name2, user.Name2)
         .Set(p => p.Name3, user.Name3)
         .Set(p => p.OtdId, user.OtdId)
         //.Set(p => p.otdid17F790F, user.otdid17F790F)
         .Set(p => p.AccessId, user.AccessId).Update();
     }
 }
예제 #5
0
        // POST: api/User
        public long Post([FromBody] dynamic value)
        {
            var o = value.ToString();
            JavaScriptSerializer jss = new JavaScriptSerializer();

            DataModels.User user = jss.Deserialize <DataModels.User>(o);

            using (WDB w = new WDB())
            {
                if (user.UserId != 0)
                {
                    w.User.SetUser(user);
                }
                else
                {
                    user.UserId = w.User.CreateUser(user);
                }
            }

            return(user.UserId);
        }
예제 #6
0
        // PUT: api/User/5
        public void Put(int id, [FromBody] dynamic value)
        {
            using (WDB w = new WDB())
            {
                var o = value.ToString();
                JavaScriptSerializer jss = new JavaScriptSerializer();
                UserTmp UserTmp          = jss.Deserialize <UserTmp>(o);

                using (Cryptor cryptor = new Cryptor()) {
                    DataModels.User user = new DataModels.User
                    {
                        UserId   = id,
                        Name1    = UserTmp.name1,
                        Name2    = UserTmp.name2,
                        Name3    = UserTmp.name3,
                        AccessId = UserTmp.AccessId,
                        Login    = UserTmp.login,
                        OtdId    = UserTmp.OtdId
                                   //Password = new Guid(cryptor.Crypt(UserTmp.password))
                    };
                    w.User.SetUser(user);
                }
            }
        }