コード例 #1
0
        public string DeletePrism(string id)
        {
            //CRUD_Data dataResult = new CRUD_Data();
            string status = "";

            try
            {
                PrismCol prismCol = db.PrismColss.Find(id);
                if (prismCol == null)
                {
                    status = "0";
                }

                db.PrismColss.Remove(prismCol);
                db.SaveChangesAsync();

                status = "200";

                return(status);
            }
            catch (Exception ex)
            {
                Log.Info(ex);
                status = "500";
                return(status);
            }
        }
コード例 #2
0
        public async Task <IHttpActionResult> DeletePrismCol(string id)
        {
            CRUD_Data dataResult = new CRUD_Data();

            try
            {
                PrismCol prismCol = await db.PrismColss.FindAsync(id);

                if (prismCol == null)
                {
                    dataResult.StatusDetails = "Not found " + id + " in system.";
                    return(BadRequest(dataResult.StatusDetails));
                }

                db.PrismColss.Remove(prismCol);
                await db.SaveChangesAsync();

                dataResult.StatusCode = "200";

                return(Ok(dataResult));
            }
            catch (Exception ex)
            {
                Log.Info(ex);
                dataResult.StatusDetails = "We found the problem in 'Delete CLBS process'(DateTime: " + DateTime.Now + " ). Please contact admin.";
                return(BadRequest(dataResult.StatusDetails));
            }
        }
コード例 #3
0
        public async Task <IHttpActionResult> PostPrismCol(PrismCol prismCol)
        {
            CRUD_Data dataResult = new CRUD_Data();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                if (PrismColExists(prismCol.cceCode))
                {
                    return(Ok(prismCol.cceCode));
                }
                else
                {
                    db.PrismColss.Add(prismCol);
                    await db.SaveChangesAsync();

                    dataResult.StatusCode = "200";
                }
            }
            catch (DbEntityValidationException e)
            {
                var newException = new FormattedDbEntityValidationException(e);
                Log.Info(newException);
                dataResult.StatusDetails = "We found the problem in 'Add CLBS process'( " + prismCol.cceCode + ") (DateTime: " + DateTime.Now + " ). Please contact admin.";
                return(BadRequest(dataResult.StatusDetails));
            }

            return(Ok(dataResult.StatusCode));
        }
コード例 #4
0
        public async Task <IHttpActionResult> GetPrismCol(string id)
        {
            PrismCol_Result dataResult = new PrismCol_Result();

            try
            {
                PrismCol prismCol = await db.PrismColss.FindAsync(id);

                if (prismCol == null)
                {
                    dataResult.StatusCode    = "404";
                    dataResult.StatusDetails = "Not found " + id + " in System";
                    return(Ok(dataResult));
                }
                dataResult.DataResult = new vPrismCol
                {
                    cceCode = prismCol.cceCode,
                    slopeRx = prismCol.slopeRx,
                    slopeRy = prismCol.slopeRy
                };
                dataResult.StatusCode = "200";
            }
            catch (Exception ex)
            {
                Log.Info(ex);
                dataResult.StatusCode    = "409";
                dataResult.StatusDetails = "We found the problem in 'GetPrismCollection data process' (DateTime: " + DateTime.Now + " ). Please contact admin.";
                return(BadRequest(dataResult.StatusDetails));
            }


            return(Ok(dataResult));
        }
コード例 #5
0
 public PrismCol getPrism(string OPC)
 {
     try
     {
         PrismCol data = db.PrismColss.Find(OPC);
         return(data);
     }
     catch (Exception ex)
     {
         PrismCol data = null;
         Log.Info(ex);
         return(data);
     }
 }
コード例 #6
0
        public async Task <IHttpActionResult> PutPrismCol(string cceCode, PrismCol prismCol)
        {
            PrismCol_Result dataResult = new PrismCol_Result();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (cceCode != prismCol.cceCode)
            {
                dataResult.StatusDetails = "" + cceCode + "is not match in System";
                return(BadRequest(dataResult.StatusDetails));
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!PrismColExists(cceCode))
                {
                    dataResult.StatusDetails = "Not found " + cceCode + " in System";
                    return(BadRequest(dataResult.StatusDetails));
                }
                else
                {
                    Log.Info(ex);
                    dataResult.StatusDetails = "We found the problem in 'Update PrismCol process' (DateTime: " + DateTime.Now + " ). Please contact admin.";
                    return(BadRequest(dataResult.StatusDetails));
                }
            }

            dataResult.StatusCode = "200";

            return(Ok(dataResult));
        }
コード例 #7
0
ファイル: CLBSData.cs プロジェクト: kamolk/CLBS_WebAPI
 public CLBSData()
 {
     PrismCol = new PrismCol();
 }