Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Implement the views for organizations #402

Open
SaintAngeLs opened this issue Sep 1, 2024 · 2 comments
Open

[FEATURE] Implement the views for organizations #402

SaintAngeLs opened this issue Sep 1, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request.

Comments

@SaintAngeLs
Copy link
Owner

#399 #400 #401 issue in the context of organization views.

@SaintAngeLs SaintAngeLs added the enhancement New feature or request. label Sep 1, 2024
@SaintAngeLs SaintAngeLs self-assigned this Sep 1, 2024
@SaintAngeLs
Copy link
Owner Author

We need to use the 2 repositories from the perspective of 2 entities: for the user as a viewer which require the relevant content and for the entity itself.

using System;

namespace MiniSpace.Services.Organizations.Core.Entities
{
    public class OrganizationView
    {
        public Guid UserId { get; private set; }
        public DateTime Date { get; private set; }
        public string IpAddress { get; private set; }
        public string DeviceType { get; private set; }
        public string OperatingSystem { get; private set; }

        public OrganizationView(Guid userId, DateTime date, string ipAddress, string deviceType, string operatingSystem)
        {
            UserId = userId;
            Date = date;
            IpAddress = ipAddress;
            DeviceType = deviceType;
            OperatingSystem = operatingSystem;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace MiniSpace.Services.Organizations.Core.Entities
{
    public class OrganizationViews
    {
        public Guid OrganizationId { get; private set; }
        public IEnumerable<OrganizationView> Views { get; private set; }

        public OrganizationViews(Guid organizationId, IEnumerable<OrganizationView> views)
        {
            OrganizationId = organizationId;
            Views = views ?? new List<OrganizationView>();
        }

        public void AddView(Guid userId, DateTime date, string ipAddress, string deviceType, string operatingSystem)
        {
            var viewList = new List<OrganizationView>(Views)
            {
                new OrganizationView(userId, date, ipAddress, deviceType, operatingSystem)
            };
            Views = viewList;
        }

        public void RemoveView(Guid userId)
        {
            var viewList = new List<OrganizationView>(Views);
            var viewToRemove = viewList.Find(view => view.UserId == userId);
            if (viewToRemove != null)
            {
                viewList.Remove(viewToRemove);
                Views = viewList;
            }
        }
    }
}


namespace MiniSpace.Services.Organizations.Core.Entities
{
    public class UserView
    {
        public Guid OrganizationId { get; private set; }
        public DateTime Date { get; private set; }
        public string IpAddress { get; private set; }
        public string DeviceType { get; private set; }
        public string OperatingSystem { get; private set; }

        public UserView(Guid organizationId, DateTime date, string ipAddress, string deviceType, string operatingSystem)
        {
            OrganizationId = organizationId;
            Date = date;
            IpAddress = ipAddress;
            DeviceType = deviceType;
            OperatingSystem = operatingSystem;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace MiniSpace.Services.Organizations.Core.Entities
{
    public class UserOrganizationsViews
    {
        public Guid UserId { get; private set; }
        public IEnumerable<UserView> Views { get; private set; }

        public UserOrganizationsViews(Guid userProfileId, IEnumerable<UserView> views)
        {
            UserId = userProfileId;
            Views = views ?? new List<UserView>();
        }

        public void AddView(Guid organizationId, DateTime date, string ipAddress, string deviceType, string operatingSystem)
        {
            var viewList = new List<UserView>(Views)
            {
                new UserView(organizationId, date, ipAddress, deviceType, operatingSystem)
            };
            Views = viewList;
        }

        public void RemoveView(Guid organizationId)
        {
            var viewList = new List<UserView>(Views);
            var viewToRemove = viewList.Find(view => view.OrganizationId == organizationId);
            if (viewToRemove != null)
            {
                viewList.Remove(viewToRemove);
                Views = viewList;
            }
        }
    }
}

@SaintAngeLs
Copy link
Owner Author

The same issue will be related to the #399, #400, #401.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

1 participant