public async Task <LoginTokenModel> AddLoginToken(LoginTokenModel loginToken)
        {
            using (DynamoDbContext dbContext = new DynamoDbContext())
            {
                await dbContext.SaveAsync(loginToken);

                var savedLoginToken = await dbContext.LoadAsync <LoginTokenModel>(loginToken.Token);

                return(savedLoginToken);
            }
        }
示例#2
0
 /// <summary>
 /// Gets a user record from the db.
 /// </summary>
 /// <param name="id"></param>
 /// <returns>User</returns>
 public async Task <UserModel> Get(string id)
 {
     using (DynamoDbContext context = new DynamoDbContext())
     {
         try
         {
             return(await context.LoadAsync <UserModel>(id));
         }
         catch (Exception e)
         {
             //ADD LOGER
             throw new Exception(e.Message);
         }
     }
 }
示例#3
0
        /// <summary>
        /// Gets the full name of the user associated with id specified.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <string> GetFullName(string id)
        {
            using (DynamoDbContext context = new DynamoDbContext())
            {
                try
                {
                    var userSearched = await context.LoadAsync <UserModel>(id);

                    return(userSearched.FirstName + " " + userSearched.LastName);
                }
                catch (Exception e)
                {
                    //ADD LOGER
                    throw new Exception(e.Message);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Get the document by id
        /// Calls the base class because there may be some generic behavior in it
        /// </summary>
        /// <typeparam name="T">generic type</typeparam>
        /// <param name="id">document id</param>
        /// <returns>generic type of document</returns>
        public override async Task <T> GetByIdAsync <T>(string entityId)
        {
            await base.GetByIdAsync <T>(entityId);

            return(await DynamoDbContext.LoadAsync <T>(entityId));
        }