Task runs a service that gets data from my web api, it then shoudl do 3 crud methods depending on a field value.
Update, Insert, and delete. Update is working.
Insert is not, nothing happens.
private void SyncProdCrudCheck(List<MWProduct> inserted)
{
foreach (var item in inserted)
{
switch (item.AD_Action)
{
case "I":
InsertSyncProd(item);
break;
case "U":
UpdateSyncProd(item);
break;
case "D":
break;
}
}
}
private void InsertSyncProd(MWProduct prod)
{
Product product = new Product();
product.Name = prod.Name;
product.ShortDescription = prod.ShortDescription;
product.FullDescription = prod.FullDescription;
product.Height = prod.Pd_height != null ? Convert.ToDecimal(prod.Pd_height) : 0;
product.Width = prod.Pd_width != null ? Convert.ToDecimal(prod.Pd_width) : 0;
product.Length = prod.Pd_depth != null ? Convert.ToDecimal(prod.Pd_depth) : 0;
product.CreatedOnUtc = DateTime.UtcNow;
product.UpdatedOnUtc = DateTime.UtcNow;
product.ProductType = ProductType.SimpleProduct;
product.ProductTemplateId = 1;
product.ShowOnHomePage = true;
_productRepos.Insert(product);
}
is this code correct, is this the best way to add a new product?