Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,050
- Reaction score
- 17,804
Lol you do know @ToxicBunny is one of us too![]()
Oh yeah ofc course bunny!
South Africa’s biggest forum. Discuss, discover, and connect with thousands of members.
Lol you do know @ToxicBunny is one of us too![]()
Oh don't mention governance, popia is a headache of note, especially when we arent in the exact path between Customer and Business.Yeah we're all bliksems lazy, and driving more than 2kms is just a hack
But same as @Kosmik , hit me up via PM for a coffee sometime.
I'm not all into the Dev space, but I can over complicate your life with Infrastructure architecture and governance/compliance crap if you want to have your head implode![]()
We can play with python and then the python programming code.Yeah we're all bliksems lazy, and driving more than 2kms is just a hack
But same as @Kosmik , hit me up via PM for a coffee sometime.
I'm not all into the Dev space, but I can over complicate your life with Infrastructure architecture and governance/compliance crap if you want to have your head implode![]()
Oh don't mention governance, popia is a headache of note, especially when we arent in the exact path between Customer and Business.
We can play with python and then the python programming code.
iirc you are in the Hillcrest area?
So Crimetown it is thenFsck popia... bloody little chihuahua. GDPR is 100x worse because its actually enforced.
I claim to live in lower Kloof![]()
So Crimetown it is then
Hehe, on the side of crimetown, on the one side of the valley/cliffsHillcrest aka Chillcrest. You guys up on that mountain are in a different world. It's lekker there. Have an aunt living there.
Does she make curry?Hillcrest aka Chillcrest. You guys up on that mountain are in a different world. It's lekker there. Have an aunt living there.
Anyone here working with Python3?
Know who to ask then. Started a course on python yesterday. Just basics right nowOn and off at a high level.. for me its a tool to test/verify things.
Know who to ask then. Started a course on python yesterday. Just basics right now
Then quick one, what is the best to use in your experience in formatting eg:Fire away with questions at any time.
Chances are you will get a "WTF, I dunno wtf you're trying to do" but hey...
print("This is a string {}".format("xxx"))
#or
print(f"This is a string {}")
Honest answer, I dunno. I never work on formatting strings at all.. I just get data and then fsck around with it in other places.
My generalised "coding" answer would be use whichever method suits the entire use case better.
// POST api/v1/identity/login
[HttpPost(ApiRoutes.Identity.Login)]
public async Task<AuthenticationResult> Login([FromBody] UserLoginRequest request)
{
return await _identityService.LoginAsync(request.Email, request.Password);
}
public class AuthenticationResult
{
public string Token { get; set; }
public string RefreshToken { get; set; }
public bool Success { get; set; }
public IEnumerable<string> Errors { get; set; }
}
Fugly. The method will return with a 200 OK if successful but will break otherwise. The api controller will handle by default as a object to return.I have one which has me a bit confused on that regard. On the API topic. I've seen someone return API results as such. No action results nothing. Any thoughts on this?
C#:// POST api/v1/identity/login [HttpPost(ApiRoutes.Identity.Login)] public async Task<AuthenticationResult> Login([FromBody] UserLoginRequest request) { return await _identityService.LoginAsync(request.Email, request.Password); }
C#:public class AuthenticationResult { public string Token { get; set; } public string RefreshToken { get; set; } public bool Success { get; set; } public IEnumerable<string> Errors { get; set; } }
Fugly. The method will return with a 200 OK if successful but will break otherwise. The api controller will handle by default as a object to return.
// GET /api/v1/users/find-by-email/{email}
[AllowAnonymous]
[HttpGet(ApiRoutes.Users.FindByEmail)]
public async Task<IActionResult> FindByEmail(string email)
{
try
{
if(email == null)
{
return BadRequest(new RequestResult<User>
{
Success = false,
Errors = new[] { "Required input missing." }
});
}
var user = await _userManager.FindByEmailAsync(email);
if (user == null)
{
return NotFound(new RequestResult<User>
{
Errors = new[] { "No records found." }
});
}
return Ok(new RequestResult<User>
{
Data = user
});
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, new RequestResult<User>
{
Success=false,
Errors = new[] { "An unexpected error occurred. Please try again later." }
});
}
}
public class RequestResult<T>
{
public T Data { get; set; }
public bool Success { get; set; } = true;
public IEnumerable<string> Errors { get; set; }
}
if(email == null)
{
return BadRequest(new RequestResult<User>
{
Success = false,
Errors = new[] { "Required input missing." }
});
}
var user = await _userManager.FindByEmailAsync(email);
if (user == null)
{
return NotFound(new RequestResult<User>
{
Errors = new[] { "No records found." }
});
}
return Ok(new RequestResult<User>
{
Data = user
});