Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

manage subscription page for premium users#62

Open
TouchySpidey wants to merge 2 commits into
devfrom
feature-manage-subscription
Open

manage subscription page for premium users#62
TouchySpidey wants to merge 2 commits into
devfrom
feature-manage-subscription

Conversation

@TouchySpidey

Copy link
Copy Markdown
Collaborator

Comment thread Application/Payments/SubscriptionRepository.cs

@ElSalvo96 ElSalvo96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TouchySpidey, see the review and let me know what do you think about

@ElSalvo96

ElSalvo96 commented Oct 4, 2023

Copy link
Copy Markdown
Member

@TouchySpidey, see the review and let me know what do you think about

Or, probably is better something like that:

    public async Task<bool> IsUserPremium(string userId)
    {
        var result =await GetSubscriptionInfo(userId)                        //take the last added
        return result?.Status == SubscriptionStatus.Active;  //and check if it is active
    }

public async Task<SubscriptioObj> GetSubscriptionInfo(string userId)
{
    var subscription = await context.Subscriptions
        .Where(s => s.UserId == userId && s.ExpiresOn > DateTime.UtcNow)
        .OrderByDescending(s => s.CreatedOn)
        .FirstOrDefaultAsync();

    return subscription
}

With that the next time you have always the last row and we can add all fields.

Note: I don't know well the code and C#, so check the code that I have written above. Probability: I'm completely wrong!

@TouchySpidey

Copy link
Copy Markdown
Collaborator Author

good ideas, but for now let's leave the code as it is
maybe open a issue to remember it as a future improvements?
@EkimoCode agrees to not overcomplicate this matter for now

@ElSalvo96

Copy link
Copy Markdown
Member

I agree! I have opened a new issue #65.
Let's close this and go forward!

After your merge remember to attach the swagger in this chat!
Nice job!

@ElSalvo96 ElSalvo96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This optimization, can be done in the future

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants