public void AddProperty(int materialId, int sourceMaterialId, int sourceId, int subgroupId, PropertyFilter propertyClient, ref ElsevierMaterials.Models.Domain.Comparison.Property propertyComparison, IMaterialsContextUow materialContextUow)
 {
     ElsevierMaterials.Models.Condition condition = _conditionBinder.FillCondition(sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient);
     propertyComparison = _propertyBinder.FillPropertyData(materialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition);
     ElsevierMaterials.Models.Domain.Comparison.Comparison comparison = GetComparison();
     comparison.Properties.Add(propertyComparison);
 }
        public ActionResult RemoveMaterial(int materialId, int sourceMaterialId, int sourceId, int subgroupId)
        {
            ComparisonD comparison1 = _ComparisonDiagramBinder.GetComparisonDiagramModel();

            ElsevierMaterials.Models.Domain.Comparison.Comparison comparison = _materialBinder.RemoveMaterial(materialId, sourceMaterialId, sourceId, subgroupId);
            ComparisonD comparisonD = _ComparisonDiagramBinder.RemoveMaterial(materialId, sourceMaterialId, sourceId, subgroupId);

            comparison.ComparisonD = comparisonD;
            return(Json(ResponseStatus.Success, new { hasProperties = comparison.Properties.Count > 0 ? true : false, data = RenderPartialViewToString("PropertiesWithDiagrams", comparison), plot = RenderPartialViewToString("Plot", comparison), model = Newtonsoft.Json.JsonConvert.SerializeObject(comparison) }, JsonRequestBehavior.AllowGet));
        }
        public void AddProperties(int materialId, int sourceMaterialId, int sourceId, int subgroupId, List <PropertyFilter> properties, IMaterialsContextUow materialContextUow)
        {
            foreach (var propertyClient in properties)
            {
                ElsevierMaterials.Models.Domain.Comparison.Comparison comparison         = GetComparison();
                ElsevierMaterials.Models.Domain.Comparison.Property   propertyComparison = GetProperty(propertyClient, comparison);

                if (propertyComparison != null)
                {
                    _materialBinder.ChangePropertyData(materialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, ref propertyComparison);
                }
                else
                {
                    ElsevierMaterials.Models.Condition condition = _conditionBinder.FillCondition(sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient);
                    propertyComparison = _propertyBinder.FillPropertyData(materialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition);
                    comparison.Properties.Add(propertyComparison);

                    ElsevierMaterials.Models.Domain.Comparison.Material material = _materialBinder.FillMaterialData(materialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, propertyComparison, null);
                    propertyComparison.Materials.Add(material);
                }
            }
        }
        public ElsevierMaterials.Models.Domain.Comparison.Property GetProperty(PropertyFilter propertyClient, ElsevierMaterials.Models.Domain.Comparison.Comparison comparison)
        {
            ElsevierMaterials.Models.Domain.Comparison.Property propertyComparison = null;

            if (propertyClient.TypeId == 0 && propertyClient.SourceTypeId > 0)
            {
                propertyComparison = comparison.Properties.Where(m => m.PropertyInfo.SourceTypeId == propertyClient.SourceTypeId).FirstOrDefault();
            }
            else if (propertyClient.TypeId > 0)
            {
                propertyComparison = comparison.Properties.Where(m => m.PropertyInfo.TypeId == propertyClient.TypeId).FirstOrDefault();
            }
            else
            {
                propertyComparison = comparison.Properties.Where(m => m.PropertyInfo.RowId == propertyClient.RowId && m.PropertyInfo.ConditionId == propertyClient.ConditionId && m.PropertyInfo.GroupId == propertyClient.GroupId).FirstOrDefault();
            }
            return(propertyComparison);
        }