private async Task <HttpResponseMessage> ExecuteAsync(CandidatureId candidatureId) { return(await _httpClient.PostAsJsonAsync( $"api/candidatures/{candidatureId}", new { })); }
public async Task <IActionResult> FindCandidatureAsync(CandidatureId candidatureId) { var candidature = await _candidatureService.FindCandidatureAsync(candidatureId); if (candidature == null) { return(this.NotFound("Candidature not found.")); } return(this.Ok(_mapper.Map <CandidatureDto>(candidature))); }
public async Task <IActionResult> DeclineCandidatureAsync(CandidatureId candidatureId) { var ownerId = HttpContext.GetUserId(); var candidature = await _candidatureService.FindCandidatureAsync(candidatureId); if (candidature == null) { return(this.NotFound("The candidature was not found.")); } var result = await _candidatureService.DeclineCandidatureAsync(candidature, ownerId); if (result.IsValid) { return(this.Ok("The candidature has been declined.")); } result.AddToModelState(ModelState); return(this.BadRequest(new ValidationProblemDetails(ModelState))); }
public async Task <Candidature?> FindCandidatureAsync(CandidatureId candidatureId) { return(await _candidatureRepository.FindAsync(candidatureId)); }
private async Task <HttpResponseMessage> ExecuteAsync(CandidatureId candidatureId) { return(await _httpClient.DeleteAsync($"api/candidatures/{candidatureId}")); }
public async Task <Candidature?> FindAsync(CandidatureId candidatureId) { return(await _context.Candidatures.AsExpandable().SingleOrDefaultAsync(candidature => candidature.Id == candidatureId)); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity <Clan>( builder => { builder.ToTable("Clan"); builder.Property(clan => clan.Id).HasConversion(clanId => clanId.ToGuid(), value => ClanId.FromGuid(value)).IsRequired().ValueGeneratedNever(); builder.Property(clan => clan.Name).IsRequired(); builder.Property(clan => clan.Summary).IsRequired(false); builder.Property(clan => clan.OwnerId).HasConversion(invitationId => invitationId.ToGuid(), value => UserId.FromGuid(value)).IsRequired(); builder.Ignore(clan => clan.Deleted); builder.HasMany(clan => clan.Members).WithOne().HasForeignKey(member => member.ClanId); builder.HasKey(clan => clan.Id); }); modelBuilder.Entity <Clan>( builder => { builder.ToTable("Clan"); builder.Property(clan => clan.Id).HasConversion(clanId => clanId.ToGuid(), value => ClanId.FromGuid(value)).IsRequired().ValueGeneratedNever(); builder.Property(clan => clan.Name).IsRequired(); builder.Property(clan => clan.Summary).IsRequired(false); builder.Property(clan => clan.OwnerId).HasConversion(invitationId => invitationId.ToGuid(), value => UserId.FromGuid(value)).IsRequired(); builder.HasMany(clan => clan.Members).WithOne().HasForeignKey(member => member.ClanId); builder.HasKey(clan => clan.Id); }); modelBuilder.Entity <Member>( builder => { builder.ToTable("Member"); builder.Property(member => member.Id).HasConversion(memberId => memberId.ToGuid(), value => MemberId.FromGuid(value)).IsRequired().ValueGeneratedNever(); builder.Property(member => member.UserId).HasConversion(userId => userId.ToGuid(), value => UserId.FromGuid(value)).IsRequired(); builder.Property(member => member.ClanId).HasConversion(clanId => clanId.ToGuid(), value => ClanId.FromGuid(value)).IsRequired(); builder.HasKey(member => member.Id); }); modelBuilder.Entity <Candidature>( builder => { builder.ToTable("Candidature"); builder.Property(candidature => candidature.Id) .HasConversion(candidatureId => candidatureId.ToGuid(), value => CandidatureId.FromGuid(value)) .IsRequired().ValueGeneratedNever(); builder.Property(candidature => candidature.UserId).HasConversion(userId => userId.ToGuid(), value => UserId.FromGuid(value)).IsRequired(); builder.Property(candidature => candidature.ClanId).HasConversion(clanId => clanId.ToGuid(), value => ClanId.FromGuid(value)).IsRequired(); builder.HasKey(candidature => candidature.Id); }); modelBuilder.Entity <Invitation>( builder => { builder.ToTable("Invitation"); builder.Property(invitation => invitation.Id) .HasConversion(invitationId => invitationId.ToGuid(), value => InvitationId.FromGuid(value)) .IsRequired().ValueGeneratedNever(); builder.Property(invitation => invitation.UserId).HasConversion(userId => userId.ToGuid(), value => UserId.FromGuid(value)).IsRequired(); builder.Property(invitation => invitation.ClanId).HasConversion(clanId => clanId.ToGuid(), value => ClanId.FromGuid(value)).IsRequired(); builder.HasKey(invitation => invitation.Id); }); modelBuilder.Entity <Division>( builder => { builder.ToTable("Division"); builder.Property(division => division.Id) .HasConversion(divisionId => divisionId.ToGuid(), value => DivisionId.FromGuid(value)) .IsRequired().ValueGeneratedNever(); builder.Property(division => division.Name).IsRequired(); builder.Property(division => division.Description).IsRequired(false); builder.Property(division => division.ClanId).HasConversion(clanId => clanId.ToGuid(), value => ClanId.FromGuid(value)).IsRequired(); builder.Ignore(division => division.Members); builder.HasKey(division => division.Id); }); }