Browse Source

Add IsPremium and PremiumEndDate to Organization

pull/69/head
Berkan Sasmaz 5 years ago
parent
commit
6f7b4ad470
  1. 2
      src/EventHub.Application.Contracts/Organizations/OrganizationInListDto.cs
  2. 4
      src/EventHub.Application.Contracts/Organizations/OrganizationProfileDto.cs
  3. 2
      src/EventHub.Application/Organizations/OrganizationAppService.cs
  4. 35
      src/EventHub.Domain/Organizations/Organization.cs
  5. 2704
      src/EventHub.EntityFrameworkCore/Migrations/20211025080208_Added_IsPremium_And_PremiumEndDate_To_Organization.Designer.cs
  6. 37
      src/EventHub.EntityFrameworkCore/Migrations/20211025080208_Added_IsPremium_And_PremiumEndDate_To_Organization.cs
  7. 6
      src/EventHub.EntityFrameworkCore/Migrations/EventHubDbContextModelSnapshot.cs

2
src/EventHub.Application.Contracts/Organizations/OrganizationInListDto.cs

@ -10,5 +10,7 @@ namespace EventHub.Organizations
public string DisplayName { get; set; }
public string Description { get; set; }
public bool IsPremium { get; set; }
}
}

4
src/EventHub.Application.Contracts/Organizations/OrganizationProfileDto.cs

@ -26,5 +26,9 @@ namespace EventHub.Organizations
public string InstagramUsername { get; set; }
public string MediumUsername { get; set; }
public bool IsPremium { get; set; }
public DateTime? PremiumEndDate { get; set; }
}
}

2
src/EventHub.Application/Organizations/OrganizationAppService.cs

@ -119,7 +119,7 @@ namespace EventHub.Organizations
public async Task<bool> IsOrganizationOwnerAsync(Guid organizationId)
{
return CurrentUser.Id.HasValue && await _organizationRepository
.AnyAsync(x => x.Id == organizationId && x.OwnerUserId == CurrentUser.Id.Value);
.AnyAsync(x => x.Id == organizationId && x.OwnerUserId == CurrentUser.GetId());
}
[Authorize]

35
src/EventHub.Domain/Organizations/Organization.cs

@ -1,6 +1,7 @@
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Timing;
namespace EventHub.Organizations
{
@ -28,6 +29,10 @@ namespace EventHub.Organizations
public int MemberCount { get; internal set; }
public bool IsPremium { get; private set; }
public DateTime? PremiumEndDate { get; private set; }
private Organization()
{
}
@ -63,5 +68,35 @@ namespace EventHub.Organizations
Description = Check.NotNullOrWhiteSpace(description, nameof(description), OrganizationConsts.MaxDescriptionNameLength, OrganizationConsts.MinDescriptionNameLength);
return this;
}
internal Organization UpgradeToPremium(IClock clock)
{
SetPremiumStatus(true, clock.Now.AddYears(1));
return this;
}
internal Organization DowngradeToPremium(IClock clock)
{
SetPremiumStatus(false);
return this;
}
private Organization SetPremiumStatus(bool isPremium, DateTime? endDate = null)
{
if (isPremium)
{
Check.NotNull(endDate, nameof(endDate));
IsPremium = true;
PremiumEndDate = endDate;
return this;
}
IsPremium = false;
return this;
}
}
}

2704
src/EventHub.EntityFrameworkCore/Migrations/20211025080208_Added_IsPremium_And_PremiumEndDate_To_Organization.Designer.cs

File diff suppressed because it is too large

37
src/EventHub.EntityFrameworkCore/Migrations/20211025080208_Added_IsPremium_And_PremiumEndDate_To_Organization.cs

@ -0,0 +1,37 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EventHub.Migrations
{
public partial class Added_IsPremium_And_PremiumEndDate_To_Organization : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsPremium",
table: "EhOrganizations",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "PremiumEndDate",
table: "EhOrganizations",
type: "timestamp with time zone",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsPremium",
table: "EhOrganizations");
migrationBuilder.DropColumn(
name: "PremiumEndDate",
table: "EhOrganizations");
}
}
}

6
src/EventHub.EntityFrameworkCore/Migrations/EventHubDbContextModelSnapshot.cs

@ -302,6 +302,9 @@ namespace EventHub.Migrations
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<bool>("IsPremium")
.HasColumnType("boolean");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("LastModificationTime");
@ -324,6 +327,9 @@ namespace EventHub.Migrations
b.Property<Guid>("OwnerUserId")
.HasColumnType("uuid");
b.Property<DateTime?>("PremiumEndDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("TwitterUsername")
.HasColumnType("text");

Loading…
Cancel
Save