Esempio n. 1
0
        public TransferBalanceOut TransferBalance(TransferBalanceIn input)
        {
            var output = new TransferBalanceOut()
            {
                result = Entities.Common.Result.Error
            };
            var request = new Business.User.User();

            var getUserInfoOut = request.GetUsers(new MethodParameters.User.GetUsersIn()
            {
            }).listUsers.FirstOrDefault(x => x.usrID == input.currentUser.usrID);
            var permissionRequest        = new Business.Permission.Permission();
            var validateAccesFunctionOut = permissionRequest.GetPermissionByRole(new MethodParameters.Permission.GetPermissionByRoleIn()
            {
                role = getUserInfoOut.usr_role
            });

            if (validateAccesFunctionOut.result == Entities.Common.Result.Success &&
                validateAccesFunctionOut.listPermissions.FirstOrDefault(x => x.pm_code == "06") != null)
            {
                var getUserOut = request.GetUser(new MethodParameters.User.GetUserIn()
                {
                    usr_userName = input.usr_userNameOrigin
                });

                if (getUserOut.result == Entities.Common.Result.Success &&
                    getUserOut.user.usr_balance >= input.valueTransfer)
                {
                    var transferBalanceOut = request.TransferBalance(new MethodParameters.User.TransferBalanceIn()
                    {
                        usr_userNameOrigin  = input.usr_userNameOrigin,
                        usr_userNameDestiny = input.usr_userNameDestiny,
                        valueTransfer       = input.valueTransfer
                    });

                    if (transferBalanceOut.result == Entities.Common.Result.Success)
                    {
                        output.message = "Transferencia realizada con exito";
                        output.result  = Entities.Common.Result.Success;
                    }
                }
                else if (getUserOut.result == Entities.Common.Result.Success)
                {
                    output.message = "El valor a transferir supera el balance de la cuenta de origen";
                    output.result  = Entities.Common.Result.Success;
                }
            }
            else if (validateAccesFunctionOut.result == Entities.Common.Result.Success)
            {
                output.message = "Esta funcionalidad no se encuentra disponible para no usuarios";
            }

            return(output);
        }
Esempio n. 2
0
        public DeleteBalanceOut DeleteBalance(DeleteBalanceIn input)
        {
            var output = new DeleteBalanceOut()
            {
                result = Entities.Common.Result.Error
            };
            var request = new Business.User.User();

            var getUserInfoOut = request.GetUsers(new MethodParameters.User.GetUsersIn()
            {
            }).listUsers.FirstOrDefault(x => x.usrID == input.currentUser.usrID);
            var permissionRequest        = new Business.Permission.Permission();
            var validateAccesFunctionOut = permissionRequest.GetPermissionByRole(new MethodParameters.Permission.GetPermissionByRoleIn()
            {
                role = getUserInfoOut.usr_role
            });

            if (validateAccesFunctionOut.result == Entities.Common.Result.Success &&
                validateAccesFunctionOut.listPermissions.FirstOrDefault(x => x.pm_code == "04") != null)
            {
                var getUserOut = request.GetUser(new MethodParameters.User.GetUserIn()
                {
                    usr_userName = input.usr_userNameDestiny
                });

                if (getUserOut.result == Entities.Common.Result.Success &&
                    getUserOut.user.usr_balance >= input.valueTransfer)
                {
                    var deleteBalanceOut = request.DeleteBalance(new MethodParameters.User.DeleteBalanceIn()
                    {
                        usr_userNameDestiny = input.usr_userNameDestiny,
                        valueTransfer       = input.valueTransfer
                    });

                    if (deleteBalanceOut.result == Entities.Common.Result.Success)
                    {
                        output.result = deleteBalanceOut.result;
                        output.result = Entities.Common.Result.Success;
                    }
                }
                else if (getUserOut.result == Entities.Common.Result.Success)
                {
                    output.message = "La operación que intenta realizar supera el balance actual";
                }
            }
            else if (validateAccesFunctionOut.result == Entities.Common.Result.Success)
            {
                output.message = "Esta funcionalidad no se encuentra disponible para usuarios no Administrador";
            }

            return(output);
        }
Esempio n. 3
0
        public CreateUserOut Create(CreateUserIn input)
        {
            var output = new CreateUserOut()
            {
                result = Entities.Common.Result.Error
            };
            var request = new Business.User.User();

            var getUserInfoOut = request.GetUsers(new MethodParameters.User.GetUsersIn()
            {
            }).listUsers.FirstOrDefault(x => x.usrID == input.currentUser.usrID);
            var permissionRequest        = new Business.Permission.Permission();
            var validateAccesFunctionOut = permissionRequest.GetPermissionByRole(new MethodParameters.Permission.GetPermissionByRoleIn()
            {
                role = getUserInfoOut.usr_role
            });

            if (validateAccesFunctionOut.result == Entities.Common.Result.Success &&
                validateAccesFunctionOut.listPermissions.FirstOrDefault(x => x.pm_code == "01") != null)
            {
                var password       = Common.Security.Encryption.Encrypt(input.usr_password, input.usr_userName);
                var createUsertOut = request.CreateUser(new MethodParameters.User.CreateUserIn()
                {
                    user = new Entities.Database.User()
                    {
                        usr_userName       = input.usr_userName,
                        usr_password       = password,
                        usr_fullName       = input.usr_fullName,
                        usr_documentType   = input.usr_documentType,
                        usr_numberDocument = input.usr_numberDocument,
                        usr_email          = input.usr_email,
                        usr_role           = input.usr_role
                    }
                });

                if (createUsertOut.result == Entities.Common.Result.Success)
                {
                    output.result = Entities.Common.Result.Success;
                }
            }
            else if (validateAccesFunctionOut.result == Entities.Common.Result.Success)
            {
                output.message = "Esta funcionalidad no se encuentra disponible para usuarios no Administrador";
            }

            return(output);
        }
Esempio n. 4
0
        public AddBalanceOut AddBalance(AddBalanceIn input)
        {
            var output = new AddBalanceOut()
            {
                result = Entities.Common.Result.Error
            };
            var request = new Business.User.User();

            var getUserOut = request.GetUsers(new MethodParameters.User.GetUsersIn()
            {
            }).listUsers.FirstOrDefault(x => x.usrID == input.currentUser.usrID);
            var permissionRequest        = new Business.Permission.Permission();
            var validateAccesFunctionOut = permissionRequest.GetPermissionByRole(new MethodParameters.Permission.GetPermissionByRoleIn()
            {
                role = getUserOut.usr_role
            });

            if (validateAccesFunctionOut.result == Entities.Common.Result.Success &&
                validateAccesFunctionOut.listPermissions.FirstOrDefault(x => x.pm_code == "03") != null)
            {
                var createUsertOut = request.AddBalance(new MethodParameters.User.AddBalanceIn()
                {
                    usr_userNameDestiny = input.usr_userNameDestiny,
                    valueTransfer       = input.valueTransfer
                });

                if (createUsertOut.result == Entities.Common.Result.Success)
                {
                    output.usrID  = createUsertOut.usrID;
                    output.result = Entities.Common.Result.Success;
                }
            }
            else if (validateAccesFunctionOut.result == Entities.Common.Result.Success)
            {
                output.message = "Esta funcionalidad no se encuentra disponible para usuarios no Administrador";
            }
            return(output);
        }