feat/estimate #50
3 changed files with 48 additions and 31 deletions
List the activities
commit
2a8a4fc4a4
|
|
@ -72,7 +72,16 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Row="2" ColumnDefinitions="*,Auto">
|
<Grid Grid.Row="2" ColumnDefinitions="*,Auto">
|
||||||
<TextBlock Grid.Column="0" Text="{Binding StatusMessage}" VerticalAlignment="Center" />
|
<TextBox Grid.Column="0"
|
||||||
|
Text="{Binding StatusMessage}"
|
||||||
|
IsReadOnly="True"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
BorderThickness="0"
|
||||||
|
BorderBrush="Transparent"
|
||||||
|
Padding="0"
|
||||||
|
Background="Transparent"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
<ProgressBar Grid.Column="1" Width="120" IsIndeterminate="True" IsVisible="{Binding IsBusy}" />
|
<ProgressBar Grid.Column="1" Width="120" IsIndeterminate="True" IsVisible="{Binding IsBusy}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -44,19 +44,23 @@ namespace Yavsc.Controllers
|
||||||
|
|
||||||
var codes = activities
|
var codes = activities
|
||||||
.Select(a => a.Code)
|
.Select(a => a.Code)
|
||||||
.Concat(activities.SelectMany(a => a.Children.Where(c => !c.Hidden).Select(c => c.Code)))
|
.Concat(activities.SelectMany(a => (a.Children ?? new List<Activity>())
|
||||||
|
.Where(c => !c.Hidden)
|
||||||
|
.Select(c => c.Code)))
|
||||||
|
.Where(c => !string.IsNullOrWhiteSpace(c))
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var performerCounts = await _context.Performers
|
var performerCounts = await (
|
||||||
.AsNoTracking()
|
from ua in _context.UserActivities.AsNoTracking()
|
||||||
.Where(p => p.Active)
|
join p in _context.Performers.AsNoTracking() on ua.UserId equals p.PerformerId
|
||||||
.SelectMany(
|
where p.Active && !string.IsNullOrWhiteSpace(ua.DoesCode) && codes.Contains(ua.DoesCode)
|
||||||
p => p.Activity
|
group ua by ua.DoesCode into g
|
||||||
.Where(a => codes.Contains(a.DoesCode))
|
select new
|
||||||
.Select(a => new { a.DoesCode, p.PerformerId }))
|
{
|
||||||
.GroupBy(x => x.DoesCode)
|
Code = g.Key,
|
||||||
.Select(g => new { Code = g.Key, Count = g.Select(x => x.PerformerId).Distinct().Count() })
|
Count = g.Select(x => x.UserId).Distinct().Count()
|
||||||
|
})
|
||||||
.ToDictionaryAsync(x => x.Code, x => x.Count, cancellationToken);
|
.ToDictionaryAsync(x => x.Code, x => x.Count, cancellationToken);
|
||||||
|
|
||||||
return Ok(activities.Select(a => ToBrowseItem(a, performerCounts)).ToList());
|
return Ok(activities.Select(a => ToBrowseItem(a, performerCounts)).ToList());
|
||||||
|
|
@ -80,29 +84,32 @@ namespace Yavsc.Controllers
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
var performers = await _context.Performers
|
var performers = await (
|
||||||
.AsNoTracking()
|
from p in _context.Performers.AsNoTracking()
|
||||||
.Include(p => p.Performer)
|
join ua in _context.UserActivities.AsNoTracking() on p.PerformerId equals ua.UserId
|
||||||
.Include(p => p.Activity)
|
join u in _context.ApplicationUser.AsNoTracking() on p.PerformerId equals u.Id into users
|
||||||
.ThenInclude(a => a.Does)
|
from user in users.DefaultIfEmpty()
|
||||||
.Where(p => p.Active && p.Activity.Any(a => a.DoesCode == id))
|
where p.Active && ua.DoesCode == id
|
||||||
.OrderBy(p => p.Rate)
|
orderby p.Rate
|
||||||
.Select(p => new ActivityPerformerDto
|
select new ActivityPerformerDto
|
||||||
{
|
{
|
||||||
PerformerId = p.PerformerId,
|
PerformerId = p.PerformerId,
|
||||||
UserName = p.Performer.UserName,
|
UserName = user != null ? (user.UserName ?? string.Empty) : string.Empty,
|
||||||
Active = p.Active,
|
Active = p.Active,
|
||||||
AcceptNotifications = p.AcceptNotifications,
|
AcceptNotifications = p.AcceptNotifications,
|
||||||
AcceptPublicContact = p.AcceptPublicContact,
|
AcceptPublicContact = p.AcceptPublicContact,
|
||||||
WebSite = p.WebSite,
|
WebSite = p.WebSite ?? string.Empty,
|
||||||
ActivityCode = id,
|
ActivityCode = id,
|
||||||
ActivityName = activity.Name,
|
ActivityName = activity.Name,
|
||||||
SettingsClassName = p.Activity
|
SettingsClassName = _context.Activities
|
||||||
.Where(a => a.DoesCode == id)
|
.Where(a => a.Code == id)
|
||||||
.Select(a => a.Does.SettingsClassName)
|
.Select(a => a.SettingsClassName)
|
||||||
.FirstOrDefault(),
|
.FirstOrDefault() ?? string.Empty,
|
||||||
ExtraActivityCount = p.Activity.Count(a => a.DoesCode != id)
|
ExtraActivityCount = _context.UserActivities
|
||||||
|
.Where(x => x.UserId == p.PerformerId && x.DoesCode != id)
|
||||||
|
.Count()
|
||||||
})
|
})
|
||||||
|
.Distinct()
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
return Ok(performers);
|
return Ok(performers);
|
||||||
|
|
@ -240,7 +247,7 @@ namespace Yavsc.Controllers
|
||||||
Photo = activity.Photo,
|
Photo = activity.Photo,
|
||||||
Rate = activity.Rate,
|
Rate = activity.Rate,
|
||||||
PerformerCount = performerCounts.TryGetValue(activity.Code, out var count) ? count : 0,
|
PerformerCount = performerCounts.TryGetValue(activity.Code, out var count) ? count : 0,
|
||||||
Forms = activity.Forms
|
Forms = (activity.Forms ?? Enumerable.Empty<CommandForm>())
|
||||||
.Select(f => new CommandFormSummaryDto
|
.Select(f => new CommandFormSummaryDto
|
||||||
{
|
{
|
||||||
Id = f.Id,
|
Id = f.Id,
|
||||||
|
|
@ -248,7 +255,7 @@ namespace Yavsc.Controllers
|
||||||
Title = f.Title,
|
Title = f.Title,
|
||||||
})
|
})
|
||||||
.ToList(),
|
.ToList(),
|
||||||
Children = activity.Children
|
Children = (activity.Children ?? Enumerable.Empty<Activity>())
|
||||||
.Where(c => !c.Hidden)
|
.Where(c => !c.Hidden)
|
||||||
.OrderByDescending(c => c.Rate)
|
.OrderByDescending(c => c.Rate)
|
||||||
.Select(c => new ActivityBrowseItemDto
|
.Select(c => new ActivityBrowseItemDto
|
||||||
|
|
@ -260,7 +267,7 @@ namespace Yavsc.Controllers
|
||||||
Photo = c.Photo,
|
Photo = c.Photo,
|
||||||
Rate = c.Rate,
|
Rate = c.Rate,
|
||||||
PerformerCount = performerCounts.TryGetValue(c.Code, out var childCount) ? childCount : 0,
|
PerformerCount = performerCounts.TryGetValue(c.Code, out var childCount) ? childCount : 0,
|
||||||
Forms = c.Forms
|
Forms = (c.Forms ?? Enumerable.Empty<CommandForm>())
|
||||||
.Select(f => new CommandFormSummaryDto
|
.Select(f => new CommandFormSummaryDto
|
||||||
{
|
{
|
||||||
Id = f.Id,
|
Id = f.Id,
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,10 @@ internal class Program
|
||||||
services.AddAuthentication("Bearer")
|
services.AddAuthentication("Bearer")
|
||||||
.AddYavscJwtBearer(builder.Configuration);
|
.AddYavscJwtBearer(builder.Configuration);
|
||||||
|
|
||||||
|
// DbContextBuilder
|
||||||
services.AddDbContext<ApplicationDbContext>(options =>
|
services.AddDbContext<ApplicationDbContext>(options =>
|
||||||
|
options.UseNpgsql(builder.Configuration.GetConnectionString(
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
|
Yavsc.Constants.YavscConnectionStringName)));
|
||||||
|
|
||||||
services.AddLocalization(options =>
|
services.AddLocalization(options =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue