Exemple #1
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);
        }
Exemple #2
0
 //[CustomAuthorizationFilterAttribute]
 public IHttpActionResult DeleteBalance(DeleteBalanceIn input)
 {
     if (ModelState.IsValid)
     {
         var user             = new SystemManagement.Business.Controllers.User();
         var deleteBalanceOut = user.DeleteBalance(input);
         return(ResponseMessage(Request.CreateResponse(System.Net.HttpStatusCode.OK, deleteBalanceOut)));
     }
     else
     {
         var output = new DeleteBalanceOut();
         output.result  = SystemManagement.Entities.Common.Result.Error;
         output.message = DetailErrorBadRequest(ModelState);
         return(ResponseMessage(Request.CreateResponse(System.Net.HttpStatusCode.BadRequest, output)));
     }
 }
Exemple #3
0
        public DeleteBalanceOut DeleteBalance(DeleteBalanceIn input)
        {
            DeleteBalanceOut output = new DeleteBalanceOut()
            {
                result = Entities.Common.Result.Error
            };

            using (var dataContext = DataContextHelper.GetDataContext <UserDataContext>())
            {
                var linqResult = dataContext.spr_setDeleteBalance(
                    input.usr_userNameDestiny,
                    input.valueTransfer
                    );
                if (linqResult.FirstOrDefault().result > 0)
                {
                    output.result = Entities.Common.Result.Success;
                }
            }
            return(output);
        }