Пример #1
0
        public static IPProductsModel Convert(ip_products ipProductsDB)
        {
            if (ipProductsDB == null)
            {
                //throw new ArgumentNullException(nameof(ipProductsDB));
            }

            return(new IPProductsModel()
            {
                product_id = ipProductsDB.product_id,
                family_id = ipProductsDB.family_id,
                other_info = ipProductsDB.other_info,
                product_description = ipProductsDB.product_description,
                product_name = ipProductsDB.product_name,
                product_price = ipProductsDB.product_price,
                product_sku = ipProductsDB.product_sku,
                provider_name = ipProductsDB.provider_name,
                purchase_org_price = ipProductsDB.purchase_org_price,
                purchase_price = ipProductsDB.purchase_price,
                quantity = ipProductsDB.quantity,
                selling_price = ipProductsDB.selling_price,
                serial_number = ipProductsDB.serial_number,
                sub_cate = ipProductsDB.sub_cate,
                supp_name = ipProductsDB.supp_name,
                tax_rate_id = ipProductsDB.tax_rate_id,
                warenty_detail = ipProductsDB.warenty_detail,
                tax_Model = Convert(ipProductsDB.ip_tax_rates),
                family_Model = Convert(ipProductsDB.ip_families)
            });
        }
Пример #2
0
        public static ip_products Map(IPProductsModel iPProductsModel, ip_products ipProductsDB)
        {
            if (iPProductsModel == null)
            {
                //throw new ArgumentNullException(nameof(iPProductsModel));
            }

            if (ipProductsDB == null)
            {
                //throw new ArgumentNullException(nameof(ipProductsDB));
            }

            ipProductsDB.family_id           = iPProductsModel.family_id;
            ipProductsDB.other_info          = iPProductsModel.other_info;
            ipProductsDB.product_description = iPProductsModel.product_description;
            ipProductsDB.product_name        = iPProductsModel.product_name;
            ipProductsDB.product_price       = iPProductsModel.product_price;
            ipProductsDB.product_sku         = iPProductsModel.product_sku;
            ipProductsDB.provider_name       = iPProductsModel.provider_name;
            ipProductsDB.purchase_org_price  = iPProductsModel.purchase_org_price;
            ipProductsDB.purchase_price      = iPProductsModel.purchase_price;
            ipProductsDB.quantity            = iPProductsModel.quantity;
            ipProductsDB.selling_price       = iPProductsModel.selling_price;
            ipProductsDB.serial_number       = iPProductsModel.serial_number;
            ipProductsDB.sub_cate            = iPProductsModel.sub_cate;
            ipProductsDB.supp_name           = iPProductsModel.supp_name;
            ipProductsDB.tax_rate_id         = iPProductsModel.tax_rate_id;
            ipProductsDB.warenty_detail      = iPProductsModel.warenty_detail;
            return(ipProductsDB);
        }
Пример #3
0
        public bool Add(IPProductsModel iPProductsModel)
        {
            if (iPProductsModel == null)
            {
                //throw new ArgumentNullException(nameof(iPProductsModel));
            }

            var allIPProductsDB = AMDSystemsEntities.ip_products.Select(p => p).Where(e => !(e.isdelete.HasValue && e.isdelete.Value)).Where(e => e.serial_number == iPProductsModel.serial_number).FirstOrDefault();

            if (allIPProductsDB != null)
            {
                return(false);
            }
            ip_products ipProductsDB = Mapper.Map(iPProductsModel, new ip_products());

            AMDSystemsEntities.ip_products.Add(ipProductsDB);
            AMDSystemsEntities.SaveChanges();
            return(true);
        }