public async Task PostOrganization([FromForm] OrganizationDto organizationDto) { var newOrganization = new Organization(); organizationDto.UpdateEntity(newOrganization); dbContext.Organizations.Add(newOrganization); await dbContext.SaveChangesAsync(); }
public async Task PutOrganization([FromForm] OrganizationDto organizationDto) { Organization organization = await dbContext.Organizations .Include(o => o.File) .FirstOrDefaultAsync(o => o.Id == organizationDto.Id); if (organizationDto.File != null && organization.File != null) { dbContext.Files.Remove(organization.File); } organizationDto.UpdateEntity(organization); await dbContext.SaveChangesAsync(); }