More Class Models

More Class Models

Categories and Stores

More Class Models

I shared the class models for Products and Variants in my last post. This is a post on the categories and stores models.

Categories

At first, I wanted to create a linked list data structure for the categories. That way the user can create categories with as many levels as they'd like. But I work in retail/wholesale and I saw that it's not that great having categories that go deeper than 3 levels. Linking the products to the bottom-most level is a challenge. Reporting at the same level also presents its own challenges. Some categories may only have 2 levels while others have 4 to 5 levels. Do you create a report for each level? Do you create unnecessary categories just so all categories have the same amount of levels?

If I keep it rigid and limit it to just two levels, it will force the user to work within those parameters. Sure, there will be users that will be left frustrated that they cannot have more than 2 levels, but I think the benefit will outweigh the lack of category levels.

The Category class model

using System;

namespace PriceBookClubClassLibrary
{
    public class Category
    {
            public int Id { get; set; }
            public string Name { get; set; }
            public int? MainCategoryId { get; set; }
            public string? MainCategoryName { get; set; }
            public bool IsSubCategory { get; set; }
            public bool IsDeleted { get; set; }
            public int UserId { get; set; }
            public string UserName { get; set; }
            public int NumberOfUsers { get; set; }
            public Date DateCreated { get; set; }
            public Date DateEdited { get; set; }
    }
}

I'm still figuring all of this out. There will be changes. So if there are errors, I will probably only find out about them once I start testing. Like for instance, there should probably be a MainCategory property with a Category datatype. But I'm not sure how I'll handle that. I'm still not sure which ORM I'm going to use. Probably Dapper or Entity Framework Core.

Stores

The store is pretty straightforward. It will probably be the first class I create and test full CRUD on. It doesn't really link to any other class, except user perhaps. But other than that, it's a no-frills, no-fuss class model. I thought about adding the store's location and referencing the latitude and longitude, but then I'll have to think about businesses shutting down and how I'll handle that. It's far too complex to implement right now.

The Store class model

using System;

namespace PriceBookClubClassLibrary
{
    public class Store
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string URL { get; set; }
        public bool IsDeleted { get; set; }
        public int CreatedByUserId { get; set; }
        public int NumberOfUsers { get; set; }
        public Date DateCreated { get; set; }
        public Date DateEdited { get; set; }
    }
}

I almost didn't post today. I was supposed to do it during my lunch hour but sat a couple of minutes after work to get it done. I'm really just flying off the cuff here and hoping that a plan will formulate itself along the way because if I don't move, I'll just find ways to procrastinate.

 
Share this