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)); }
public async Task <META_BO> GetMETAForCommitAsync(long id) { META_BO meta = await db.META_BO .Where(x => x.META_BO_ID == id) .IncludeFilter(x => x.META_FIELD.Where(f => !f.FORM_TYPE.Contains("subform-"))) .FirstOrDefaultAsync(); return(meta); }
// FOR COMMIT public async Task <META_BO> GetMETAForCommitAsync(string dbName) { META_BO meta = await db.META_BO .Where(x => x.BO_DB_NAME == dbName) .IncludeFilter(x => x.META_FIELD.Where(f => !f.FORM_TYPE.Contains("subform-"))) .FirstOrDefaultAsync(); return(meta); }
public META_BO GetMETA(long id) { META_BO meta = db.META_BO .Where(x => x.META_BO_ID == id) .IncludeFilter(x => x.META_FIELD.Where(f => f.STATUS != "NEW")) .FirstOrDefault(); return(meta); }
public async Task <META_BO> GetMETAAsync(long id) { META_BO meta = await db.META_BO .Where(x => x.META_BO_ID == id) .IncludeFilter(x => x.META_FIELD.Where(f => f.STATUS != "NEW")) .FirstOrDefaultAsync(); return(meta); }
public META_BO GetMETA(string dbName) { META_BO meta = db.META_BO .Where(x => x.BO_DB_NAME == dbName) .IncludeFilter(x => x.META_FIELD.Where(f => f.STATUS != "NEW" && !f.STATUS.Contains("[deleted]"))) .FirstOrDefault(); return(meta); }
public async Task <META_BO> GetMETAAsync(string dbName) { META_BO meta = await db.META_BO .Where(x => x.BO_DB_NAME == dbName) .IncludeFilter(x => x.META_FIELD.Where(f => f.STATUS != "NEW" && !f.STATUS.Contains("[deleted]")).OrderBy(y => y.META_FIELD_ID)) .FirstOrDefaultAsync(); return(meta); }
public async Task <IHttpActionResult> GetDefinition(string id) { META_BO mETA_BO = await new MetaBoRepo().GetMETAAsync(id); if (mETA_BO == null) { return(NotFound()); } return(Ok(mETA_BO)); }
public META_BO Create(META_BO mETA_BO, string userName) { mETA_BO.BO_DB_NAME = Helper.cleanDBName(mETA_BO.BO_DB_NAME == null ? mETA_BO.BO_NAME : mETA_BO.BO_DB_NAME) + "_BO_"; mETA_BO.VERSION = 1; mETA_BO.CREATED_BY = userName; mETA_BO.UPDATED_BY = userName; mETA_BO.CREATED_DATE = DateTime.Now; mETA_BO.UPDATED_DATE = DateTime.Now; return(mETA_BO); }
public async Task <IHttpActionResult> GetMETA_BO(long id) { META_BO mETA_BO = await db.META_BO.FindAsync(id); if (mETA_BO == null) { return(NotFound()); } return(Ok(mETA_BO)); }
public async Task <META_BO> CreateAndSaveAsync(META_BO mETA_BO, string userName) { mETA_BO = Create(mETA_BO, userName); db.META_BO.Add(mETA_BO); VERSIONS version = new VersionsRepo().Create(mETA_BO.META_BO_ID, userName); db.VERSIONS.Add(version); await db.SaveChangesAsync(); return(mETA_BO); }
public async Task <IHttpActionResult> DeleteMETA_BO(long id) { META_BO mETA_BO = await db.META_BO.FindAsync(id); if (mETA_BO == null) { return(NotFound()); } db.META_BO.Remove(mETA_BO); await db.SaveChangesAsync(); return(Ok(mETA_BO)); }
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); }
public async Task <IHttpActionResult> PutMETA_BO(long id, META_BO mETA_BO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } META_BO meta = await db.META_BO.FindAsync(id); if (meta == null) { return(BadRequest("META_BO NOT FOUND !")); } meta.BO_NAME = mETA_BO.BO_NAME; meta.TYPE = mETA_BO.TYPE; meta.JSON_DATA = mETA_BO.JSON_DATA; meta.UPDATED_BY = User.Identity.Name; meta.UPDATED_DATE = DateTime.Now; db.Entry(meta).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!META_BOExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostMETA_BO(META_BO mETA_BO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //mETA_BO.BO_DB_NAME += "_BO_"; //mETA_BO.VERSION = 1; //mETA_BO.CREATED_BY = User.Identity.Name; //mETA_BO.UPDATED_BY = User.Identity.Name; //mETA_BO.CREATED_DATE = DateTime.Now; //mETA_BO.UPDATED_DATE = DateTime.Now; //db.META_BO.Add(mETA_BO); //// int lastVersion = db.VERSIONS.Where(x => x.META_BO_ID == mETA_BO.META_BO_ID).Max(x => x.NUM); //db.VERSIONS.Add(new VERSIONS() //{ // META_BO_ID = mETA_BO.META_BO_ID, // NUM = 1, // SQLQUERY = Helper.GetSQL("CreateTable.sql"), // STATUS = "PENDING", // CREATED_BY = User.Identity.Name, // UPDATED_BY = User.Identity.Name, //}); //await db.SaveChangesAsync(); try { mETA_BO = await new MetaBoRepo().CreateAndSaveAsync(mETA_BO, User.Identity.Name); } catch (Exception ex) { Logger.Error(ex, "POST META_BO"); } return(CreatedAtRoute("DefaultApi", new { id = mETA_BO.META_BO_ID }, mETA_BO)); }