Example #1
0
 public static void Insert(WF_M_USERDEPT entity)
 {
     using (var db = Pub.DB)
     {
         db.Insert <WF_M_USERDEPT>(entity);
     }
 }
        public override int Update(FormM form, DFDictionary entity, ref string message)
        {
            var currentUser = Util.GetCurrentUser();

            if (string.IsNullOrWhiteSpace(entity["UserId"]))
            {
                throw new ArgumentNullException("UserId");
            }

            var list = JsonSerializeHelper.DeserializeObject <List <VM_WF_M_USERDEPT> >(Base64StringHelper.ConvertFromBase64String(entity[DFPub.GetKey_GridHiddenValue("grid1")]));

            if (list == null)
            {
                throw new Exception("Invalid grid data");
            }

            WF_M_USERDEPTLoader.DeleteByUserId(entity["UserId"]);
            list.Where(a => a.selected).ToList().ForEach(a =>
            {
                var ud            = new WF_M_USERDEPT();
                ud.PK_GUID        = Guid.NewGuid().ToString();
                ud.DeptId         = a.DeptId;
                ud.UserId         = entity["UserId"];
                ud.CreateUser     = currentUser.UserName;
                ud.CreateTime     = DateTime.Now;
                ud.LastModifyUser = currentUser.UserName;
                ud.LastModifyTime = DateTime.Now;
                WF_M_USERDEPTLoader.Insert(ud);
            });
            message = "保存成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
Example #3
0
 public static void Update(WF_M_USERDEPT entity)
 {
     using (var db = Pub.DB)
     {
         db.Update <WF_M_USERDEPT>(entity);
     }
 }