joren
joren
CC#
Created by joren on 12/14/2023 in #help
Using base class as relationship definition in model ASP.net WEB API
public class UserCredentialsModel : IdentityUser, IModelEntity
{
[Required]
string Id { get; set; }

[Required]
public DateTime CreatedAt { get; set; }

public ICollection<RefreshTokenModel> RefreshTokens { get; } = new List<RefreshTokenModel>();

public CompanyUserModel? CompanyProfile { get; set; }
public PanelUserModel? PanelProfile { get; set; }
public PortalManagerUserModel? PortalManagerProfile { get; set; }

}
public class UserCredentialsModel : IdentityUser, IModelEntity
{
[Required]
string Id { get; set; }

[Required]
public DateTime CreatedAt { get; set; }

public ICollection<RefreshTokenModel> RefreshTokens { get; } = new List<RefreshTokenModel>();

public CompanyUserModel? CompanyProfile { get; set; }
public PanelUserModel? PanelProfile { get; set; }
public PortalManagerUserModel? PortalManagerProfile { get; set; }

}
is what I did now, is this a decent solution or am I looking at it the wrong way?
3 replies
CC#
Created by joren on 12/14/2023 in #help
Using base class as relationship definition in model ASP.net WEB API
I would assume I'd need all my profiles inside UserCredentialsModel, make them nullable and define the relation in OnModelCreate accordingly?
3 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
I see, makes sense
177 replies
CC#
Created by Sk on 12/9/2023 in #help
just begun learning ASP.NET Core MVC and am looking for any good material to help me
the MVC part in your message threw me off, as that stands for Model Controller View which is used in ASP.net Web Api's
15 replies
CC#
Created by Sk on 12/9/2023 in #help
just begun learning ASP.NET Core MVC and am looking for any good material to help me
oh, shit I misread, yes it is.
15 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
though that doesnt stop me from writing a incomplete DTO...
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
I guess I should mark whatever is required as required
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
thats a risk I carry
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
but my relations might get missed that way
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
I'd change my DTO to just the pokemon data
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
if I wanted to limit it to just adding a pokemon
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
to add a pokemon...
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
and a bunch more, seems like a large input to be given
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
now when I add a pokemon, it looks like this:
{
"name": "string",
"birthDate": "2023-12-09T18:50:55.382Z",
"reviews": [
{
"id": 0,
"title": "string",
"text": "string",
"reviewer": {
"id": 0,
"firstName": "string",
"lastName": "string",
"reviews": [
"string"
{
"name": "string",
"birthDate": "2023-12-09T18:50:55.382Z",
"reviews": [
{
"id": 0,
"title": "string",
"text": "string",
"reviewer": {
"id": 0,
"firstName": "string",
"lastName": "string",
"reviews": [
"string"
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
how does my end point look, does it look good?
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
ah fair, makes sense
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
[HttpPost]
public async Task<ActionResult<PokemonGetDTO>> Post(PokemonCreateDTO dto)
{
var entity = _mapper.Map<Pokemon>(dto);

await _repository.Add(entity);

var createdDto = _mapper.Map<PokemonGetDTO>(entity);
return CreatedAtAction(nameof(Get), new { id = entity.Id }, createdDto);
}
[HttpPost]
public async Task<ActionResult<PokemonGetDTO>> Post(PokemonCreateDTO dto)
{
var entity = _mapper.Map<Pokemon>(dto);

await _repository.Add(entity);

var createdDto = _mapper.Map<PokemonGetDTO>(entity);
return CreatedAtAction(nameof(Get), new { id = entity.Id }, createdDto);
}
So now this Post request, will require all fields except those that are nullable correct?
177 replies
CC#
Created by joren on 12/9/2023 in #help
How are DTO utilized
and the reason I do this is, when I try to create, it will require me for the information I have in my PokemonCategorySubDTO, rather than the model itself?
177 replies
CC#
Created by Novascar on 12/9/2023 in #help
Visual Studio doesnt show errors and projects
No description
44 replies