Example #1
0
        public HttpResponseMessage addPlan(dynamic pPlan)
        {
            try
            {
                using (PRINCE_STGEntities dbCtx = new PRINCE_STGEntities())
                {
                    STG_PLAN plan = new STG_PLAN();
                    plan.PLAN_DATE                 = pPlan.PLAN_DATE;
                    plan.GEO_LEVEL1_CODE           = "99999";
                    plan.GEO_LEVEL2_CODE           = "99999";
                    plan.GEO_LEVEL3_CODE           = "99999";
                    plan.STORE_CODE                = pPlan.STORE_CODE;
                    plan.PROD_LEVEL1_CODE          = pPlan.PROD_LEVEL1_CODE;
                    plan.PROD_LEVEL2_CODE          = pPlan.PROD_LEVEL2_CODE;
                    plan.PROD_LEVEL3_CODE          = pPlan.PROD_LEVEL3_CODE;
                    plan.PROD_LEVEL4_CODE          = "99999";
                    plan.PROD_LEVEL5_CODE          = "99999";
                    plan.PRODUCT_CODE              = "99999";
                    plan.PLAN_VERSION              = 99999;
                    plan.PLAN_SALE_QTY             = 99999;
                    plan.PLAN_SALE_VAL_AT_PRICE    = pPlan.PLAN_SALE_VAL_AT_PRICE;
                    plan.PLAN_SALE_VAL_AT_COST     = 99999;
                    plan.PLAN_MARKDOWN_QTY         = 0;
                    plan.PLAN_MARKDOWN_VAL         = 0;
                    plan.PLAN_SHRINKAGE_VAL        = 0;
                    plan.PLAN_PURCHASE_QTY         = 0;
                    plan.PLAN_PURCHASE_VAL         = 0;
                    plan.PLAN_INV_OPENING_QTY      = 0;
                    plan.PLAN_OPENING_VAL_AT_COST  = 0;
                    plan.PLAN_OPENING_VAL_AT_PRICE = 0;
                    plan.PLAN_OTH1                 = 99999;
                    plan.PLAN_OTH2                 = 99999;
                    plan.PLAN_OTH3                 = 99999;
                    plan.PLAN_OTH4                 = 99999;
                    plan.PLAN_OTH5                 = 99999;
                    plan.ARC_DATE = DateTime.Now;

                    dbCtx.STG_PLAN.Add(plan);
                    dbCtx.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.Created, "Plan successfully created."));
                }
            }
            catch (Exception ex)
            {
                Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
            }
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Example #2
0
 public HttpResponseMessage updatePlan(dynamic pPlan)
 {
     try
     {
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             using (var dbCtxTran = enBi.Database.BeginTransaction())
             {
                 //DateTime plandate = pPlan.PLAN_DATE;
                 int id = pPlan.ID;
                 //string storecode = pPlan.STORE_CODE;
                 STG_PLAN plan = enBi.STG_PLAN.Find(id);
                 if (plan != null)
                 {
                     plan.ID                        = pPlan.ID;
                     plan.PLAN_DATE                 = pPlan.PLAN_DATE;
                     plan.GEO_LEVEL1_CODE           = pPlan.GEO_LEVEL1_CODE;
                     plan.GEO_LEVEL2_CODE           = pPlan.GEO_LEVEL2_CODE;
                     plan.GEO_LEVEL3_CODE           = pPlan.GEO_LEVEL3_CODE;
                     plan.STORE_CODE                = pPlan.STORE_CODE;
                     plan.PROD_LEVEL1_CODE          = pPlan.PROD_LEVEL1_CODE;
                     plan.PROD_LEVEL2_CODE          = pPlan.PROD_LEVEL2_CODE;
                     plan.PROD_LEVEL3_CODE          = pPlan.PROD_LEVEL3_CODE;
                     plan.PROD_LEVEL4_CODE          = pPlan.PROD_LEVEL4_CODE;
                     plan.PROD_LEVEL5_CODE          = pPlan.PROD_LEVEL5_CODE;
                     plan.PRODUCT_CODE              = pPlan.PRODUCT_CODE;
                     plan.PLAN_VERSION              = pPlan.PLAN_VERSION;
                     plan.PLAN_SALE_QTY             = pPlan.PLAN_SALE_QTY;
                     plan.PLAN_SALE_VAL_AT_PRICE    = pPlan.PLAN_SALE_VAL_AT_PRICE;
                     plan.PLAN_SALE_VAL_AT_COST     = pPlan.PLAN_SALE_VAL_AT_COST;
                     plan.PLAN_MARKDOWN_QTY         = pPlan.PLAN_MARKDOWN_QTY;
                     plan.PLAN_MARKDOWN_VAL         = pPlan.PLAN_MARKDOWN_VAL;
                     plan.PLAN_SHRINKAGE_VAL        = pPlan.PLAN_SHRINKAGE_VAL;
                     plan.PLAN_PURCHASE_QTY         = pPlan.PLAN_PURCHASE_QTY;
                     plan.PLAN_PURCHASE_VAL         = pPlan.PLAN_PURCHASE_VAL;
                     plan.PLAN_INV_OPENING_QTY      = pPlan.PLAN_INV_OPENING_QTY;
                     plan.PLAN_OPENING_VAL_AT_COST  = pPlan.PLAN_OPENING_VAL_AT_COST;
                     plan.PLAN_OPENING_VAL_AT_PRICE = pPlan.PLAN_OPENING_VAL_AT_PRICE;
                     plan.PLAN_OTH1                 = pPlan.PLAN_OTH1;
                     plan.PLAN_OTH2                 = pPlan.PLAN_OTH2;
                     plan.PLAN_OTH3                 = pPlan.PLAN_OTH3;
                     plan.PLAN_OTH4                 = pPlan.PLAN_OTH4;
                     plan.PLAN_OTH5                 = pPlan.PLAN_OTH5;
                     plan.ARC_DATE                  = pPlan.ARC_DATE;
                     enBi.Entry(plan).State         = System.Data.Entity.EntityState.Modified;
                     enBi.SaveChanges();
                     dbCtxTran.Commit();
                     return(Request.CreateResponse(HttpStatusCode.OK, "Plan successfully Updated."));
                 }
             }
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     return(Request.CreateResponse(HttpStatusCode.OK, "Plan successfully Updated."));
 }