コード例 #1
0
        public static DTO_SYS_Apps post_SYS_Apps(AppEntities db, DTO_SYS_Apps item, string Username)
        {
            tbl_SYS_Apps dbitem = new tbl_SYS_Apps();

            if (item != null)
            {
                dbitem.Code                  = item.Code;
                dbitem.Name                  = item.Name;
                dbitem.Remark                = item.Remark;
                dbitem.Sort                  = item.Sort;
                dbitem.IsDisabled            = item.IsDisabled;
                dbitem.IsDeleted             = item.IsDeleted;
                dbitem.AppSecret             = item.AppSecret;
                dbitem.IdentityTokenLifetime = item.IdentityTokenLifetime;
                dbitem.AccessTokenLifetime   = item.AccessTokenLifetime;
                dbitem.RequireConsent        = item.RequireConsent;
                dbitem.AppColor              = item.AppColor;

                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;


                try
                {
                    db.tbl_SYS_Apps.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_SYS_Apps", dbitem.ModifiedDate, Username);


                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_SYS_Apps", e);
                    item = null;
                }
            }
            return(item);
        }
コード例 #2
0
        public static bool put_SYS_Apps(AppEntities db, int ID, DTO_SYS_Apps item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_SYS_Apps.Find(ID);

            if (dbitem != null)
            {
                dbitem.Code                  = item.Code;
                dbitem.Name                  = item.Name;
                dbitem.Remark                = item.Remark;
                dbitem.Sort                  = item.Sort;
                dbitem.IsDisabled            = item.IsDisabled;
                dbitem.IsDeleted             = item.IsDeleted;
                dbitem.AppSecret             = item.AppSecret;
                dbitem.IdentityTokenLifetime = item.IdentityTokenLifetime;
                dbitem.AccessTokenLifetime   = item.AccessTokenLifetime;
                dbitem.RequireConsent        = item.RequireConsent;
                dbitem.AppColor              = item.AppColor;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_SYS_Apps", dbitem.ModifiedDate, Username);

                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_SYS_Apps", e);
                    result = false;
                }
            }
            return(result);
        }