Developing Model using Typescript

So now lets create a Model class using TypeScript. I am going to create a Products class and going to have some properties to it. This will used in the controller to bind the values retrieved from service and display it in HTML page. The following class diagram depicts the methods and properties of the Products class and the TypeScritp code is given below.

ModelDiagram

module app.Models.Products{
    export class Products{
        private _productId: number = 0;
        private _productName: string = "";
        private _productCode: string = "";
        private _releaseDate: Date = new Date(2016, 3, 25);
        private _productDescription: string;
        private _price: number;
        private _imageUrl:string;
        private _productCategory:string;

        constructor(id: number, name: string,
        code: string, releaseDate: Date,
        description: string, price: number,
        imageUrl: string, category: string){
            this._productId = id;
            this._productName = name;
            this._productCode = code;
            this._releaseDate = releaseDate;
            this._productDescription = description;
            this._price = price;
            this._imageUrl = imageUrl;
            this._productCategory = category;
        }

        public get Price(): number
        {
            return this._price;
        }

        public set Price(value: number)
        {
             this._price = value;
        }

        public get ProductId(): number
        {
            return this._productId;
        }

        public set ProductId(value: number)
        {
             this._productId = value;
        }

        public get ProductName(): string
        {
            return this._productName;
        }

        public set ProductName(value: string)
        {
             this._productName = value;
        }

        public get ProductCode(): string
        {
            return this._productCode;
        }

        public set ProductCode(value: string)
        {
             this._productCode = value;
        }

        public get Description(): string
        {
            return this._productDescription;
        }

        public set Description(value: string)
        {
             this._productDescription = value;
        }

        public get ReleaseDate(): Date
        {
            return this._releaseDate;
        }

        public set ReleaseDate(value: Date)
        {
             this._releaseDate = value;
        }

        public get ImageUrl(): string
        {
            return this._imageUrl;
        }

        public set ImageUrl(value: string)
        {
             this._imageUrl = value;
        }

        public get ProductCategory(): string
        {
            return this._productCategory;
        }

        public set ProductCategory(value: string)
        {
             this._productCategory = value;
        }

    }
}


			

One thought on “Developing Model using Typescript

  1. Pingback: Adventure with Typescript and AngularJS | dotnetjaikum

Leave a comment