Esempio n. 1
0
        /// <summary>
        /// Update NodeDetail's Infomation
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public bool UpdateItem(WFNodeDetail o, params System.Linq.Expressions.Expression <Func <WFNodeDetail, object> >[] properties)
        {
            var item = db.WFNodeDetails.Where(i => i.NodeDetailID == o.NodeDetailID).SingleOrDefault();

            if (item != null)
            {
                foreach (var propertie in properties)
                {
                    var lambda = (LambdaExpression)propertie;
                    MemberExpression memberExpression;
                    if (lambda.Body is UnaryExpression)
                    {
                        memberExpression = (MemberExpression)((UnaryExpression)lambda.Body).Operand;
                    }
                    else
                    {
                        memberExpression = (MemberExpression)lambda.Body;
                    }

                    string propertyName = memberExpression.Member.Name;
                    item.GetType().GetProperty(propertyName).SetValue(item, o.GetType().GetProperty(propertyName).GetValue(o));
                }
                db.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        public bool DeleteItem(string sItemID)
        {
            WFNodeDetail item = db.WFNodeDetails.Where(i => i.NodeDetailID == sItemID).SingleOrDefault();

            if (item != null)
            {
                db.WFNodeDetails.Remove(item);
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        public string InsertItem(WFNodeDetail o)
        {
            // o = new WFNodeDetail();
            o.NodeDetailID = Guid.NewGuid().ToString();
            o.Status       = 1;
            o.WFNode       = null;
            o.User         = null;

            db.WFNodeDetails.Add(o);
            db.SaveChanges();

            return(o.NodeDetailID);
        }