public IHttpActionResult AddBalance(AddBalanceIn input) { if (ModelState.IsValid) { var user = new SystemManagement.Business.Controllers.User(); var addBalanceOut = user.AddBalance(input); return(ResponseMessage(Request.CreateResponse(System.Net.HttpStatusCode.OK, addBalanceOut))); } else { var output = new AddBalanceOut(); output.result = SystemManagement.Entities.Common.Result.Error; output.message = DetailErrorBadRequest(ModelState); return(ResponseMessage(Request.CreateResponse(System.Net.HttpStatusCode.BadRequest, output))); } }
public AddBalanceOut AddBalance(AddBalanceIn input) { AddBalanceOut output = new AddBalanceOut() { result = Entities.Common.Result.Error }; using (var dataContext = DataContextHelper.GetDataContext <UserDataContext>()) { var linqResult = dataContext.spr_setAddBalance( input.usr_userNameDestiny, input.valueTransfer ); if (linqResult > 0) { output.usrID = linqResult; output.result = Entities.Common.Result.Success; } } return(output); }
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); }