Exemple #1
0
        /// <summary>
        /// Update DocumentType's Infomation
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public bool UpdateItem(WFDocumentType o, params System.Linq.Expressions.Expression <Func <WFDocumentType, object> >[] properties)
        {
            var item = db.WFDocumentTypes.Where(i => i.DocumentTypeID == o.DocumentTypeID).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);
        }
Exemple #2
0
 public string InsertItem(WFDocumentType o)
 {
     o.DocumentTypeID = Guid.NewGuid().ToString();
     db.WFDocumentTypes.Add(o);
     db.SaveChanges();
     return(o.DocumentTypeID);
 }
Exemple #3
0
        public bool DeleteItem(string sItemID)
        {
            WFDocumentType item = db.WFDocumentTypes.Where(i => i.DocumentTypeID == sItemID).SingleOrDefault();

            if (item != null)
            {
                if (item.WFNodes.Count > 0)
                {
                    return(false);
                }

                db.WFDocumentTypes.Remove(item);
                db.SaveChanges();
                return(true);
            }
            return(false);
        }