/// <summary>
        /// Creates a user in DBV
        /// </summary>
        /// <param name="userEntity"></param>
        /// <returns></returns>
        public Guid CreateUser(CustomerAPI userEntity)
        {
            using (var scope = new TransactionScope())
            {
                var userHMIS = new CustomerAPI
                {
                    EmailAddress = userEntity.EmailAddress,
                    UserAgent = userEntity.UserAgent,
                    //  password = EncryptText("wgt_hmis", userEntity.password),
                    FirstName = userEntity.FirstName,
                    LastName = userEntity.LastName,
                    Address1 = userEntity.Address1,
                    Address2 = userEntity.Address2,
                    City = userEntity.City,
                    CreatedOn = DateTime.Now,
                    // CreatedBy = "To be done",
                    Postcode = userEntity.Postcode,
                    Password = userEntity.Password,
                    AuthData = userEntity.AuthData

                };
                _dynamoDataService.Store(userHMIS);
                //  _unitOfWork.Save();
                scope.Complete();
                return userHMIS.Id;
            }
        }
示例#2
0
        //Public Methods
        public string Register(UserLoginDTO userDTO)
        {
            if (IsEmailAvailable(userDTO.Email))
            {
                string token;
                User   userToRegister = new User()
                {
                    Email = userDTO.Email, Password = userDTO.Password
                };
                try
                {
                    _dynamo.Store(userToRegister);
                }
                catch (Exception)
                {
                    throw new FaildToConnectDbException();
                }

                token = _tokenManager.GenerateToken(userToRegister.UserId, userToRegister.Email);
                CreateUserNodeOnGraphDb(userToRegister.UserId, userToRegister.Email);
                CreateUserIdentity(userToRegister.UserId, userToRegister.Email, token);

                return(token);
            }
            else
            {
                throw new AlreadyExistException("Email");
            }
        }
 //Private Methods
 private void CreateUserIdentity(UserIdentity updatedUserIdentity)
 {
     try
     {
         _dynamo.Store(updatedUserIdentity);
     }
     catch (Exception)
     {
         throw new FaildToConnectDbException();
     }
 }
示例#4
0
        //Private Methods
        private void AddToTokenHistory(string userId, string token)
        {
            TokenHistory tokenHistory = new TokenHistory()
            {
                UserId    = userId,
                TimeStamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds,
                Token     = token
            };

            try
            {
                _dynamo.Store(tokenHistory);
            }
            catch (Exception)
            {
                throw new FaildToConnectDbException();
            }
        }
示例#5
0
 /// <summary>
 ///  AddSample will accept a Sample object and creates an Item on Amazon DynamoDB
 /// </summary>
 /// <param name="sample"></param>
 public void AddSample(Sample sample)
 {
     _dynamoService.Store(sample);
 }
示例#6
0
 /// <summary>
 ///  AddDVD will accept a DVD object and creates an Item on Amazon DynamoDB
 /// </summary>
 /// <param name="dvd"></param>
 public void AddDvd(DVD dvd)
 {
     _dynamoService.Store(dvd);
 }
 public void AddRes(Reservation res)
 {
     _dynamoService.Store(res);
 }