コード例 #1
0
        public void CreateMetaBo(string userName)
        {
            userName = "******" + userName;
            MetaBoRepo   borepo = new MetaBoRepo();
            VersionsRepo vrepo  = new VersionsRepo();

            META_BO mbo = new META_BO
            {
                BO_NAME    = BoName,
                BO_DB_NAME = BoName,
                TYPE       = "form"
            };

            mbo = borepo.Create(mbo, userName);
            db.META_BO.Add(mbo);

            VERSIONS version = vrepo.Create(mbo.META_BO_ID, userName);

            db.VERSIONS.Add(version);

            // db.SaveChanges();

            foreach (var f in Fields)
            {
                db.META_FIELD.Add(new MetaFieldRepo().Create(f.MetaField(mbo.META_BO_ID, userName), userName));
            }
            db.SaveChanges();

            Task.Run(async() => await vrepo.CommitAsync(version.VERSIONS_ID, userName));
        }
コード例 #2
0
        public async Task <IHttpActionResult> PutVERSIONS(long id, VERSIONS vERSIONS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vERSIONS.VERSIONS_ID)
            {
                return(BadRequest());
            }

            db.Entry(vERSIONS).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VERSIONSExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
ファイル: VersionsRepo.cs プロジェクト: SimoRML/admin.mvc.js
        public async System.Threading.Tasks.Task <VERSIONS> CreateAndSaveAsync(long metaBoId, string userName)
        {
            VERSIONS v = Create(metaBoId, userName);

            db.VERSIONS.Add(v);
            await db.SaveChangesAsync();

            return(v);
        }
コード例 #4
0
        public async Task <IHttpActionResult> PostVERSIONS(VERSIONS vERSIONS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.VERSIONS.Add(vERSIONS);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = vERSIONS.VERSIONS_ID }, vERSIONS));
        }
コード例 #5
0
        public async Task <IHttpActionResult> DeleteVERSIONS(long id)
        {
            VERSIONS vERSIONS = await db.VERSIONS.FindAsync(id);

            if (vERSIONS == null)
            {
                return(NotFound());
            }

            db.VERSIONS.Remove(vERSIONS);
            await db.SaveChangesAsync();

            return(Ok(vERSIONS));
        }
コード例 #6
0
ファイル: VersionsRepo.cs プロジェクト: SimoRML/admin.mvc.js
        public async System.Threading.Tasks.Task CommitAsync(long id, string userName)
        {
            VERSIONS vERSIONS = await db.VERSIONS.FindAsync(id);

            if (vERSIONS == null)
            {
                throw new Exception("VERSION NOT FOUND");
            }

            META_BO mETA_BO = await new MetaBoRepo().GetMETAForCommitAsync(vERSIONS.META_BO_ID.Value);

            if (mETA_BO.META_FIELD.Count <= 0)
            {
                throw new Exception("No meta field found !");
            }

            var fields = "";

            foreach (var f in mETA_BO.META_FIELD)
            {
                fields += string.Format(" [{0}] {1} {2} , "
                                        , f.DB_NAME
                                        , f.DB_TYPE == "DateTime" ? " varchar(20) " : f.DB_TYPE
                                        , f.DB_NULL == 0 ? " NOT NULL " : " NULL "
                                        );
            }

            var sqlQuery = Helper.GetSQL("CreateTable.sql");

            sqlQuery = string.Format(sqlQuery,
                                     vERSIONS.VERSIONS_ID.ToString()
                                     , mETA_BO.BO_DB_NAME
                                     , fields
                                     , userName
                                     , mETA_BO.META_BO_ID.ToString()
                                     , vERSIONS.NUM
                                     , mETA_BO.BO_DB_NAME);


            sqlQuery = sqlQuery.Replace("[SQLQUERY]", sqlQuery.Replace("'", "''"));

            var s = new SGBD();

            s.Cmd(sqlQuery);
        }