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

manage subscription page for premium users #62

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

TouchySpidey
Copy link
Collaborator

Copy link
Member

@ElSalvo96 ElSalvo96 left a comment

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
Copy link
Member

ElSalvo96 commented Oct 4, 2023

@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
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
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!

Copy link
Member

@ElSalvo96 ElSalvo96 left a comment

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