Exemplo n.º 1
0
 public UserInformationDTO ValidateUser(string userName, string password)
 {
     try
     {
         var results = _userTableRepository.ValidateUser(userName, password);
         if (results != null)
         {
             var objUserRole     = _userRoleRepository.GetUserRolesByuserID(results.UserID);
             var userInformation = new UserInformationDTO
             {
                 UserID = results.UserID,
                 RoleID = objUserRole.RoleID,
                 Name   = results.FirstName + " " + results.LastName
             };
             log.Info("User Validated Successfully");
             return(userInformation);
         }
         return(null);
     }
     catch (Exception ex)
     {
         log.ErrorFormat("Exception occured while Validating the User Ex:{0}", ex.Message);
         return(null);
     }
 }
Exemplo n.º 2
0
        public async Task <UserViewModel> getcurrentUser(string apiToken)
        {
            try
            {
                var user     = new UserInformationDTO();
                var userView = new UserViewModel();
                var url      = _configuration.GetSection("ZoomEndpoints:Endpoints:2:url").Value;
                using (var httpClient = new HttpClient())
                {
                    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiToken);
                    var response = await httpClient.GetAsync(url);

                    string apiResponse = await response.Content.ReadAsStringAsync();

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        var res = JsonConvert.DeserializeObject <UserInformationDTO>(apiResponse);
                        user     = res;
                        userView = _mapper.Map <UserViewModel>(user);
                    }
                    else
                    {
                        var resError = JsonConvert.DeserializeObject <ApiResponseDTO>(apiResponse);
                        throw new Exception(resError.message.ToString());
                    }
                }
                return(userView);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public static List <UserInformationDTO> addIdentity(List <STAFF> users, String identity)
        {
            List <UserInformationDTO> userList = new List <UserInformationDTO>();

            foreach (STAFF user in users)
            {
                UserInformationDTO userInformationDTO = new UserInformationDTO();
                userInformationDTO._id        = user.STAFF_ID;
                userInformationDTO._name      = user.NAME;
                userInformationDTO._identity  = identity;
                userInformationDTO._phone     = user.PHONE;
                userInformationDTO._sign_date = user.SIGN_DATE;
                userList.Add(userInformationDTO);
            }
            return(userList);
        }
Exemplo n.º 4
0
        public async Task <bool> SaveUserInformation(UserInformationDTO userInformation)
        {
            ResponseModel model = await _rc.PostDataAsync(PostActionMethods.SaveUserInformation, userInformation);

            if (model.IsSuccessStatusCode)
            {
                UserDTO user = GetUser();
                user.Name             = userInformation.FirstName;
                user.Phone            = userInformation.Phone;
                user.Email            = userInformation.Email;
                user.Family           = userInformation.LastName;
                user.HasNotifications = userInformation.HasNotifications;
                DataBase.Instance.Update(user);
            }

            return(model.IsSuccessStatusCode);
        }