コード例 #1
0
        // Update Custom Property
        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool UpdateCustomProperty(List <CustomProperty> list)
        {
            List <tblCustomProperty> customPropertyList    = new List <tblCustomProperty>();
            List <tblCustomProperty> customPropertyListNew = new List <tblCustomProperty>();
            tblCustomProperty        customProperty        = new tblCustomProperty();

            foreach (var itm in list)
            {
                if (itm.CustomPropertyGuid != Guid.Empty)
                {
                    customProperty       = bringlyEntities.tblCustomProperties.Where(x => x.CustomPropertyGuid == itm.CustomPropertyGuid).FirstOrDefault();
                    customProperty.Field = itm.Field;
                    customProperty.Value = itm.Value;
                    bringlyEntities.SaveChanges();
                }
                else
                {
                    customProperty = new tblCustomProperty();
                    customProperty.LocationGuid       = itm.LocationGuid;
                    customProperty.CustomPropertyGuid = Guid.NewGuid();
                    customProperty.Field = itm.Field;
                    customProperty.Value = itm.Value;
                    customPropertyListNew.Add(customProperty);
                }
            }

            bringlyEntities.tblCustomProperties.AddRange(customPropertyListNew);
            bringlyEntities.SaveChanges();

            return(true);
        }
コード例 #2
0
        // Delete Custom Property
        /// <summary>
        ///
        /// </summary>
        /// <param name="customFieldGuid"></param>
        /// <returns></returns>
        public bool DeleteCustomProperty(Guid customFieldGuid)
        {
            tblCustomProperty customProperty = bringlyEntities.tblCustomProperties.Where(x => x.CustomPropertyGuid == customFieldGuid).FirstOrDefault();

            bringlyEntities.Entry(customProperty).State = EntityState.Deleted;
            bringlyEntities.SaveChanges();
            return(true);
        }
コード例 #3
0
        // Add Custom Property
        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool AddCustomProperty(List <CustomProperty> list)
        {
            List <tblCustomProperty> customPropertyList = new List <tblCustomProperty>();
            tblCustomProperty        customProperty     = new tblCustomProperty();

            foreach (var itm in list)
            {
                customProperty = new tblCustomProperty();
                customProperty.LocationGuid       = itm.LocationGuid;
                customProperty.CustomPropertyGuid = Guid.NewGuid();
                customProperty.Field = itm.Field;
                customProperty.Value = itm.Value;
                customPropertyList.Add(customProperty);
            }
            bringlyEntities.tblCustomProperties.AddRange(customPropertyList);
            bringlyEntities.SaveChanges();

            return(true);
        }