コード例 #1
0
        /// <summary>
        /// Updates a user
        /// </summary>
        /// <param name="usertId"></param>
        /// <param name="userEntity"></param>
        /// <returns></returns>
        //public bool UpdateUser(Guid userId, BusinessEntities.CustomerAPI userEntity)
        //{
        //    var success = false;
        //    if (userEntity != null)
        //    {
        //        using (var scope = new TransactionScope())
        //        {
        //            var user = _unitOfWork.UserRepository.GetByID(userId);
        //            if (user != null)
        //            {
        //                user.SID = userEntity.SID;
        //                _unitOfWork.UserRepository.Update(user);
        //                _unitOfWork.Save();
        //                scope.Complete();
        //                success = true;
        //            }
        //        }
        //    }
        //    return success;
        //}

        /// <summary>
        /// Deletes a particular user
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        //public bool DeleteUser(Guid userId)
        //{
        //    var success = false;
        //    if (userId != null && userId != Guid.Empty)
        //    {
        //        using (var scope = new TransactionScope())
        //        {
        //            var product = _unitOfWork.UserRepository.GetByID(userId);
        //            if (product != null)
        //            {

        //                _unitOfWork.UserRepository.Delete(product);
        //                _unitOfWork.Save();
        //                scope.Complete();
        //                success = true;
        //            }
        //        }
        //    }
        //    return success;
        //}

        /// <summary>
        /// Fetches product details by id
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public UserEntity GetUserById(string userId, string userType)
        {
            // UserEntity responseUser = new UserEntity();
            QueryFilter filter = new QueryFilter();
            filter.AddCondition("EmailAddress", QueryOperator.Equal, userType); //company is a parameter
            filter.AddCondition("UserType", QueryOperator.Equal, userType); //company is a parameter
            QueryOperationConfig config = new QueryOperationConfig()
            {
                Filter = filter,
                //Select = SelectValues.SpecificAttributes,
                //AttributesToGet = new List<string> { "AuthData", "Password", "FirstName", "LastName", "EmailAddress" },
                ConsistentRead = true
            };

            // var userData = _dynamoDataService.QueryItem<CustomerAPI>(userId, userType, config).FirstOrDefault();
            var userData = _dynamoDataService.GetEnumerable<CustomerAPI>(userId, userType).FirstOrDefault();
            if (userData != null)
            {
                // Mapper.CreateMap<hmis_user_base, hmisUserBase>();
                //Mapper.Reset();
                //Mapper.Initialize(cfg =>
                //{
                //    cfg.CreateMap<hmis_user_base, hmisUserBase>();
                //    //cfg.CreateMap<hmis_link_role_persmissions, hmisRolePermissions>();
                //    //cfg.CreateMap<hmis_permission_base, hmisPermisionBase>();

                //});
                //var userModel = Mapper.Map<hmis_user_base, hmisUserBase>(user);

                var responseUser = new UserEntity
                {
                    UserId = userData.EmailAddress,
                    UserName = userData.EmailAddress,
                    Password = userData.Password,
                    FirstName = userData.FirstName,
                    LastName = userData.LastName
                };

                return responseUser;
            }
            return null;
        }