Juicy
Juicy
Explore posts from servers
NNuxt
Created by Juicy on 4/26/2025 in #❓・help
Production environmental variables
Hi, I use IIS for hosting and im trying to setup my environmental variable that i use in runtime config. How do i do that on prod? I remember using some file to do it before but I forgot...
4 replies
CC#
Created by Juicy on 4/26/2025 in #help
DbConcurrencyException, what am I missing?
Hi, getting this on the SaveChangesAsync and im not really sure what im doing wrong. DbConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. Inside UserService.cs:
public async Task SetVariable(Guid productId, Guid userId, string requestKey, string requestValue)
{
var product = await productRepository.GetByIdAsync(productId);
if (product is null)
{
throw new ProductNotFoundException(productId);
}

var user = await userRepository.GetByIdAsync(productId, userId);
if (user is null)
{
throw new UserNotFoundException(userId);
}

user.SetVariable(requestKey, requestValue);
userRepository.Update(user);
await unitOfWork.SaveChangesAsync();
}
public async Task SetVariable(Guid productId, Guid userId, string requestKey, string requestValue)
{
var product = await productRepository.GetByIdAsync(productId);
if (product is null)
{
throw new ProductNotFoundException(productId);
}

var user = await userRepository.GetByIdAsync(productId, userId);
if (user is null)
{
throw new UserNotFoundException(userId);
}

user.SetVariable(requestKey, requestValue);
userRepository.Update(user);
await unitOfWork.SaveChangesAsync();
}
Inside User.cs:
public ICollection<UserVariable> Variables { get; set; }

public void SetVariable(string key, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(key);

var existingVariable = Variables.FirstOrDefault(v => v.Key.Equals(key, StringComparison.OrdinalIgnoreCase));

if (existingVariable != null)
{
existingVariable.UpdateValue(value);
}
else
{
var newVariable = UserVariable.Create(Guid.NewGuid(), Id, key, value);
Variables.Add(newVariable);
}
}
public ICollection<UserVariable> Variables { get; set; }

public void SetVariable(string key, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(key);

var existingVariable = Variables.FirstOrDefault(v => v.Key.Equals(key, StringComparison.OrdinalIgnoreCase));

if (existingVariable != null)
{
existingVariable.UpdateValue(value);
}
else
{
var newVariable = UserVariable.Create(Guid.NewGuid(), Id, key, value);
Variables.Add(newVariable);
}
}
Inside UserRepository.cs:
public void Update(User user)
{
dbContext.Set<User>().Update(user);
}
public void Update(User user)
{
dbContext.Set<User>().Update(user);
}
62 replies
CC#
Created by Juicy on 9/14/2023 in #help
❔ SignalR for real-time REST api data in WPF?
Hey, Im working on a hobby WPF application that needs to consume a rest api for real-time updates on game camera positions. Since the camera position data is always updating I want my wpf app to reflect those updates in realtime....would signalR be a good solution or is api polling good enough? Or anyone has any other recommendations for a straightforward way to ensure the client recieves near real-time updates from the rest api? Thanks!
45 replies
CC#
Created by Juicy on 12/14/2022 in #help
No route matches supplied values but values seem to match?
Hi I am getting this error on return CreatedAtAction:
System.InvalidOperationException: No route matches the supplied values.
System.InvalidOperationException: No route matches the supplied values.
var response = new UserResponse(
user.Id,
user.ProductId,
user.Username,
user.Role,
user.CreatedOnUtc);

var actionName = nameof(GetByIdAsync);
var routeValues = new {productId, id = user.Id, cancellationToken};

return CreatedAtAction(actionName, routeValues, response);
var response = new UserResponse(
user.Id,
user.ProductId,
user.Username,
user.Role,
user.CreatedOnUtc);

var actionName = nameof(GetByIdAsync);
var routeValues = new {productId, id = user.Id, cancellationToken};

return CreatedAtAction(actionName, routeValues, response);
[HttpGet("{id:guid}")]
public async Task<ActionResult> GetByIdAsync(Guid productId, Guid id,
CancellationToken cancellationToken = default)
{
[HttpGet("{id:guid}")]
public async Task<ActionResult> GetByIdAsync(Guid productId, Guid id,
CancellationToken cancellationToken = default)
{
But how are the route values incorrect when im giving it productId and the userId? To note, they also exist in the same controller and user.Id + productId are both guids (productId comes from parameter).Dont really understand what im missing here, let me know if you need me to provide more information
38 replies