public ENResult insert(uspGEProductSearch_Result data, IList <ENProductProperty> listProperty) { try { using (erpStoreEntities db = new erpStoreEntities()) { ObjectParameter objIdProduct = new ObjectParameter("idProduct", 0); db.uspGEProductInsert(data.idCategory, data.idBrand, data.codeUnit, data.name, data.divisible, data.divisibleCodeUnit, data.divisibleNumberParts, data.perishable, data.traceable, data.barcodeType, PUser, objIdProduct, PReturnCode, PReturnMessage); if (Convert.ToInt32(PReturnCode.Value) == 0) { if (listProperty != null) { for (int i = 0; i < listProperty.Count; i++) { ENProductProperty temp = listProperty[i]; db.uspGEProductPropertyInsert(Convert.ToInt32(objIdProduct.Value), temp.name, temp.abbreviation, temp.required, PUser, PReturnCode, PReturnMessage); if (Convert.ToInt32(PReturnCode.Value) != 0) { break; } } } return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value))); } else { return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value))); } } } catch (Exception ex) { return(PUnexpectedError(ex)); } }