示例#1
0
        public async Task <UserResponseData> Register(UserModel user)
        {
            try
            {
                var RegisterResult = await userEntity.IsUserRegistered(user);

                if (RegisterResult.UserName == null)
                {
                    userResponseData = new UserResponseData
                    {
                        Message = RegisterResult.Message
                    };
                    return(userResponseData);
                }
                else
                {
                    userResponseData = new UserResponseData
                    {
                        UserName    = RegisterResult.UserName,
                        Email       = RegisterResult.Email,
                        Password    = RegisterResult.PasswordHash,
                        DateCreated = RegisterResult.DateCreated
                    };

                    return(userResponseData);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        /// <summary>
        /// Crea un usuario en base de datos, crea el usuario rol como invitado temporal
        /// crear la información detalle del usuario con los datos vacios
        /// </summary>
        /// <param name="user">usuario a crear</param>
        /// <returns>UserResponseData</returns>
        public UserResponseData SaveUser(UserRequest user)
        {
            UserResponseData response = new UserResponseData();

            try
            {
                var userAppModel = user.RequestToModel();
                if (_unitOfWork.User.ExistData(x => x.UserName == userAppModel.UserName))
                {
                    response.Fail($"Ya existe un usuario con el nombre {userAppModel.UserName}, verifique!!");
                    return(response);
                }

                Guid guestRole      = _unitOfWork.Parameters.GetValueFromKey <Guid>("RolInvitadoId");
                Guid thirdId        = _unitOfWork.Parameters.GetValueFromKey <Guid>("EmptyGuid");
                int  typeDocumentCC = _unitOfWork.Parameters.GetValueFromKey <int>("TipoCedulaId");

                using (var trx = new TransactionScope())
                {
                    _unitOfWork.User.Create(userAppModel);

                    var userInfo = new UserInfoDetail()
                    {
                        UserId               = userAppModel.UserId,
                        DateCreated          = DateTime.Now,
                        UserCreatedId        = user.CreateId,
                        TypeIdentificationId = typeDocumentCC
                    };

                    _unitOfWork.UserInfoDetail.Create(userInfo);

                    var role = new UserRole()
                    {
                        UserId        = userAppModel.UserId,
                        DateCreated   = DateTime.Now,
                        RolId         = guestRole,
                        ThirdId       = thirdId,
                        UserCreatedId = user.CreateId,
                        UserRolStatus = true,
                        UserRolId     = Guid.NewGuid()
                    };

                    _unitOfWork.UserRoles.Create(role);
                    trx.Complete();
                }

                var userResponse = userAppModel.ModelToResponse();

                response.Response = userResponse;
                response.SuccesRequest($"Usuario con id {userAppModel.UserId} creado correctamente");
            }
            catch (Exception ex)
            {
                Logger.ErrorFatal($"{nameof(SaveUser)}", ex);
                response.Fail(ex);
            }
            return(response);
        }
示例#3
0
        /// <summary>
        /// Подгружаю информацию о клиенте.
        /// </summary>
        private async void ResetUser()
        {
            // Получаю информацию о клиенте.
            UserModel userJson = new UserModel {
                UserId = StaticUser.UserId
            };

            var myHttpClient = new HttpClient();

            var uri = new Uri("http://geometry.tmc-centert.ru/api/serviceapi/loggedin/");

            //json структура.
            var formContent = new FormUrlEncodedContent(new Dictionary <string, string>
            {
                { "userId", userJson.UserId }
            });

            HttpResponseMessage response = await myHttpClient.PostAsync(uri.ToString(), formContent);

            string s_result;

            using (HttpContent responseContent = response.Content)
            {
                s_result = await responseContent.ReadAsStringAsync();
            }

            UserApiData      o_data      = JsonConvert.DeserializeObject <UserApiData>(s_result);
            UserResponseData o_user_data = new UserResponseData();

            o_user_data = o_data.ResponseData;

            StaticUser.AddInfoUser(o_user_data);

            // Получаю данные об настройках клиента.
            uri = new Uri("http://geometry.tmc-centert.ru/api/serviceapi/usersettings?userId=" + userJson.UserId);

            HttpResponseMessage responseUserSettings = await myHttpClient.GetAsync(uri);

            string s_resultUserSettings = "";

            using (HttpContent responseContent1 = responseUserSettings.Content) {
                s_resultUserSettings = await responseContent1.ReadAsStringAsync();
            }

            UserSettingsApiData      o_dataSettings      = JsonConvert.DeserializeObject <UserSettingsApiData>(s_resultUserSettings);
            UserSettingsResponseData o_user_dataSettings = new UserSettingsResponseData();

            o_user_dataSettings = o_dataSettings.ResponseData;

            StaticUser.AddInfoUserSettings(o_user_dataSettings);
        }
示例#4
0
        /// <summary>
        /// Modifica el correo del usuario en base de datos
        /// </summary>
        /// <param name="user">usuario a modificar</param>
        /// <returns>UserResponseData</returns>
        public UserResponseData UpdateMailUser(UserRequest user)
        {
            UserResponseData response = new UserResponseData();

            try
            {
                var userAppModel = user.RequestToModel();

                if (!_unitOfWork.User.ExistData(x => x.UserId == userAppModel.UserId))
                {
                    response.Fail($"No existe el usuario con id {userAppModel.UserId}, verifique!!");
                    return(response);
                }

                if (_unitOfWork.User.ExistData(x => x.UserName == userAppModel.UserName && x.UserId != userAppModel.UserId))
                {
                    response.Fail($"Ya existe un usuario con el nombre {userAppModel.UserName}, verifique!!");
                    return(response);
                }


                var userBd = _unitOfWork.User.GetById(userAppModel.UserId);

                userBd.UserMail     = userAppModel.UserMail;
                userBd.UserUpdateId = user.CreateId;
                userBd.DateModified = DateTime.Now;

                _unitOfWork.User.Update(userBd);

                var userResponse = userBd.ModelToResponse();

                response.Response = userResponse;
                response.SuccesRequest($"Usuario con id {userAppModel.UserId} modificado correctamente");
            }
            catch (Exception ex)
            {
                Logger.ErrorFatal($"{nameof(UpdateMailUser)}", ex);
                response.Fail(ex);
            }
            return(response);
        }
示例#5
0
 public WebGuildUser(UserResponseData userData, SocketGuildUser guildUser) : base(userData)
 {
     _guildUser = guildUser;
 }