<commit_before>﻿/// <reference path="~/GeneratedArtifacts/viewModel.js" />

myapp.CatalogueItemView.deleteEntity_execute = function (screen) {
    deleteEntity(screen, "CatalogueItem");
};
myapp.CatalogueItemView.addToCart_execute = function (screen) {
    var title = "Add to cart";
    var entity = "CatalogueItem";
    var messageAddedToCart = "Item added to cart.";

    if (null === screen || undefined === screen || (0 >= screen.length)) {
        console.log("addToCart: 'screen': Parameter validation FAILED.");
        return;
    }

    var catalogueItem = screen[entity];

    var cartItem = myapp.activeDataWorkspace.CoreData.CartItems.addNew();
    cartItem.Tid = "00000000-0000-0000-0000-000000000000";
    cartItem.Id = 0;
    cartItem.CreatedBy = "USER";
    cartItem.ModifiedBy = "USER";
    cartItem.Parameters = '{}';
    cartItem.Created = new Date();
    cartItem.Modified = new Date();

    cartItem.Name = catalogueItem.Name;
    cartItem.CartId = "0";
    cartItem.Quantity = 1;
    cartItem.CatalogueItemId = catalogueItem.Id;

    myapp.activeDataWorkspace.CoreData.saveChanges().then(function () {
        msls.showMessageBox(
            messageAddedToCart,
            {
                title: title,
                buttons: msls.MessageBoxButtons.ok
            }
        );
    });
};<commit_msg>fixed addToCart function on detail screen<commit_after>﻿/// <reference path="~/GeneratedArtifacts/viewModel.js" />

myapp.CatalogueItemView.deleteEntity_execute = function (screen) {
    deleteEntity(screen, "CatalogueItem");
};
myapp.CatalogueItemView.addToCart_execute = function (screen) {
    var title = "Add to cart";
    var messageAddedToCart = "Item added to cart.";

    if (null === screen || undefined === screen || (0 >= screen.length)) {
        console.log("addToCart: 'screen': Parameter validation FAILED.");
        return;
    }

    var catalogueItem = screen.CatalogueItem1;

    var cartItem = myapp.activeDataWorkspace.CoreData.CartItems.addNew();
    cartItem.Tid = "00000000-0000-0000-0000-000000000000";
    cartItem.Id = 0;
    cartItem.CreatedBy = "USER";
    cartItem.ModifiedBy = "USER";
    cartItem.Parameters = '{}';
    cartItem.Created = new Date();
    cartItem.Modified = new Date();

    cartItem.Name = catalogueItem.Name;
    cartItem.CartId = "0";
    cartItem.Quantity = 1;
    cartItem.CatalogueItemId = catalogueItem.Id;

    alert(catalogueItem.Name);

    myapp.activeDataWorkspace.CoreData.saveChanges().then(function () {
        msls.showMessageBox(
            messageAddedToCart,
            {
                title: title,
                buttons: msls.MessageBoxButtons.ok
            }
        );
    });
};
{'fraction_non_alphanumeric': 0.12978802528821123, 'fraction_numerical': 0.02714763852733358, 'mean_word_length': 2.88728323699422, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4338328', 'n_tokens_mistral': 868, 'n_tokens_neox': 790, 'n_words': 151}