Esempio n. 1
0
        /// <summary>
        /// add a new product and map it to a category
        /// </summary>
        /// <param name="productCategoryId"></param>
        /// <param name="productName"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public Guid ProductAdd(
            Guid productCategoryId,
            string productName,
            Guid userId
            )
        {
            // add product
            var productContract = new CrudeProductContract();

            productContract.ProductId   = Guid.NewGuid();
            productContract.ProductName = productName;
            productContract.StateRcd    = DefaultStateRef.Created;
            productContract.UserId      = userId;
            productContract.DateTime    = DateTime.UtcNow;

            var productBll = new CrudeProductService();

            productBll.Insert(productContract);

            // map to category
            var productCategoryMapping = new CrudeProductCategoryMappingContract();

            productCategoryMapping.ProductCategoryMappingId = Guid.NewGuid();
            productCategoryMapping.ProductId         = productContract.ProductId;
            productCategoryMapping.ProductCategoryId = productCategoryId;
            productCategoryMapping.UserId            = userId;
            productCategoryMapping.DateTime          = DateTime.UtcNow;

            var mappingBll = new CrudeProductCategoryMappingService();

            mappingBll.Insert(productCategoryMapping);

            return(productContract.ProductId);
        }
 // copy all rows from a List of SOAP Contracts to a List of serialized data objects
 // links:
 //  docLink: http://sql2x.org/documentationLink/1c6c6b9c-e201-4590-8c69-d38a0ad2a9f7
 public static void ContractListToDataList(List <CrudeProductCategoryMappingContract> contractList, List <CrudeProductCategoryMappingData> dataList)
 {
     foreach (CrudeProductCategoryMappingContract contract in contractList)
     {
         var data = new CrudeProductCategoryMappingData();
         CrudeProductCategoryMappingService.ContractToData(contract, data);
         dataList.Add(data);
     }
 }