/// <summary> /// Update Node's Infomation /// </summary> /// <param name="o"></param> /// <returns></returns> public bool UpdateItem(WFDelegate o, params System.Linq.Expressions.Expression <Func <WFDelegate, object> >[] properties) { var item = db.WFDelegates.Where(i => i.DelegateID == o.DelegateID).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); }
public string InsertItem(WFDelegate o, int iUserID) { o.MainUserID = iUserID; o.DelegateID = Guid.NewGuid().ToString(); o.Temp1 = o.Temp1 == "null" ? null : o.Temp1; o.Temp3 = null; o.Temp2 = o.Temp2 == null ? null : o.Temp2; o.Status = 1; db.WFDelegates.Add(o); db.SaveChanges(); return(o.DelegateID); }
public bool DeleteItem(string sID) { WFDelegate item = db.WFDelegates.Where(i => i.DelegateID == sID).SingleOrDefault(); if (item != null) { //db.WFDelegates.Remove(item); item.Status = 0; db.SaveChanges(); return(true); } return(false); }