CoreVisional
CoreVisional
CC#
Created by CoreVisional on 2/21/2024 in #help
Difference in using the second overloaded method and first method from CosmosClient
Yeah I take it that that is for the primary key. But, I can also just connect using the first method by providing the connection string, which works just as fine for me, so I don't get the point of the second overloaded method, unless it is for explicitness and flexibility?
36 replies
CC#
Created by CoreVisional on 2/21/2024 in #help
Difference in using the second overloaded method and first method from CosmosClient
Sorry, forgot to provide the code section I was referring to: From CosmosClient.cs:
public CosmosClient(string connectionString, CosmosClientOptions clientOptions = null)
: this(CosmosClientOptions.GetAccountEndpoint(connectionString), CosmosClientOptions.GetAccountKey(connectionString), clientOptions)
{
}

public CosmosClient(string accountEndpoint, string authKeyOrResourceToken, CosmosClientOptions clientOptions = null)
{
if (string.IsNullOrEmpty(accountEndpoint))
{
throw new ArgumentNullException("accountEndpoint");
}

if (string.IsNullOrEmpty(authKeyOrResourceToken))
{
throw new ArgumentNullException("authKeyOrResourceToken");
}

Endpoint = new Uri(accountEndpoint);
AccountKey = authKeyOrResourceToken;
ClientContext = ClientContextCore.Create(this, clientOptions);
}
public CosmosClient(string connectionString, CosmosClientOptions clientOptions = null)
: this(CosmosClientOptions.GetAccountEndpoint(connectionString), CosmosClientOptions.GetAccountKey(connectionString), clientOptions)
{
}

public CosmosClient(string accountEndpoint, string authKeyOrResourceToken, CosmosClientOptions clientOptions = null)
{
if (string.IsNullOrEmpty(accountEndpoint))
{
throw new ArgumentNullException("accountEndpoint");
}

if (string.IsNullOrEmpty(authKeyOrResourceToken))
{
throw new ArgumentNullException("authKeyOrResourceToken");
}

Endpoint = new Uri(accountEndpoint);
AccountKey = authKeyOrResourceToken;
ClientContext = ClientContextCore.Create(this, clientOptions);
}
36 replies
CC#
Created by CoreVisional on 12/9/2022 in #help
Refactoring long if statement that checks for user roles
how to check for true : false here btw? I'm looking to return false if the second variable is true for example.
public static bool IsAdmin(this ClaimsPrincipal principal)
{
var roles = new[] { "Admin", "Department" };

var userRoles = principal.Claims.Where(x => roles.Contains(ClaimTypes.Role));
var excludeRole = principal.Claims.Where(x => ClaimTypes.Role.Contains("Candidate"));
}
public static bool IsAdmin(this ClaimsPrincipal principal)
{
var roles = new[] { "Admin", "Department" };

var userRoles = principal.Claims.Where(x => roles.Contains(ClaimTypes.Role));
var excludeRole = principal.Claims.Where(x => ClaimTypes.Role.Contains("Candidate"));
}
22 replies
CC#
Created by CoreVisional on 12/9/2022 in #help
Refactoring long if statement that checks for user roles
Does IsInRole checks for the entire role name or part of it? Like, if I just specify "Department", does it verify all "Department.A", "Department.B", etc?
22 replies
CC#
Created by CoreVisional on 12/9/2022 in #help
Refactoring long if statement that checks for user roles
Wait, so it's something like public static bool (this IPrincipal user) and not public static bool (this User user)?
22 replies
CC#
Created by CoreVisional on 12/9/2022 in #help
Refactoring long if statement that checks for user roles
Ahh okay, I went and try to create the custom extension check in one razor view.... so i was stuck trying to figure out how to do it
22 replies
CC#
Created by CoreVisional on 12/9/2022 in #help
Refactoring long if statement that checks for user roles
I'm still confused as in how does this relate to checking for the roles.
22 replies
CC#
Created by CoreVisional on 12/9/2022 in #help
Refactoring long if statement that checks for user roles
Hmm, extension method?
22 replies
CC#
Created by CoreVisional on 11/27/2022 in #help
✅ Cannot convert from string[] to 'char' [SOLVED]
Ahh...alright, it's solved now. Thank you.
4 replies
CC#
Created by CoreVisional on 11/26/2022 in #help
❔ How to pass anchor tag values to controller to render view based on selected value
Got it. Btw, since I'm using numbers as indication, is it possible have the url parameter to not show the numbers and instead show something else? Like if the user clicks on All locations, the parameter should be /Location/AllLocations, and not /Location/Summary?viewsIndicator=1
8 replies
CC#
Created by CoreVisional on 11/26/2022 in #help
❔ How to pass anchor tag values to controller to render view based on selected value
Seems like I can use either one
8 replies
CC#
Created by CoreVisional on 11/26/2022 in #help
❔ How to pass anchor tag values to controller to render view based on selected value
Is asp-route-id and asp-route-{value} the same thing?
8 replies
CC#
Created by CoreVisional on 11/26/2022 in #help
❔ Save each specified value in an input field as a whole when there are multiple tags in input field
So..it won't be saved into something like
Classroom Name Floor Level
CL05-01,CL05-02 1
Classroom Name Floor Level
CL05-01,CL05-02 1
?
7 replies
CC#
Created by CoreVisional on 11/24/2022 in #help
Get data from a model and display it as dropdown on client side in Razor
@friedice Is it the [BindProperty] attribute? If so, which model do I put the "bind" on? I'm assuming it's the "Block" model right?
5 replies
CC#
Created by CoreVisional on 11/24/2022 in #help
✅ Shorten data querying line
Thank you, and sorry for the confusing title btw
7 replies
CC#
Created by CoreVisional on 11/24/2022 in #help
✅ Shorten data querying line
Ahh, this is what I was looking for
7 replies
CC#
Created by CoreVisional on 11/21/2022 in #help
❔ The type or namespace name Model could not be found
Hmm, alright. I'll do a double check again on my code first before using global because it seems to work for the other models but not for this specific View Model
8 replies
CC#
Created by CoreVisional on 11/21/2022 in #help
❔ The type or namespace name Model could not be found
Okay it seems like I can't edit the post while on phone, forgot to include the name. Anyways, the error is still there even with the name
8 replies
CC#
Created by CoreVisional on 11/21/2022 in #help
❔ The type or namespace name Model could not be found
As for my ViewImports, I already have
@using Test.EntityModels.Models
@using Test.EntityModels.Models
8 replies
CC#
Created by CoreVisional on 11/19/2022 in #help
❔ Naming enum value for level or floor for a building
I'm using EF Core. But yeah, I found enums to be easily understood, at least for me. But since I'm looking to dynamically add the block / levels, I think I might need to ditch enum as I'll be hardcoding the floor numbers
25 replies