コード例 #1
0
        //// GET: api/LPLotNum
        //public IEnumerable<string> Get()
        //{
        //    return new string[] { "value1", "value2" };
        //}

        //// GET: api/LPLotNum/5
        //public string Get(int id)
        //{
        //    return "value";
        //}

        public HttpResponseMessage Get(string Company = null, string PartNum = null, string LotNum = null)
        {
            try
            {
                if (!string.IsNullOrEmpty(PartNum) && !string.IsNullOrEmpty(Company) && !string.IsNullOrEmpty(LotNum))
                {
                    string          errMsg = "";
                    BusinessLayer   BL     = new BusinessLayer();
                    PalletSelection entity = BL.GetLotFromLoose(Company, PartNum, LotNum, ref errMsg);
                    if (entity != null && errMsg == "")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                    else if (errMsg != "")
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, errMsg));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                           $"LotNum {LotNum} was not belong to the selected product!"));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                       $"PartNum Or Company Or LotNum is Null!"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message.ToString()));
            }
        }
コード例 #2
0
        //public HttpResponseMessage Get(string Company=null,string UD108Key1=null, string SysRowId=null)
        //{
        //    try
        //    {

        //        if (!string.IsNullOrEmpty(Company)
        //                    && !string.IsNullOrEmpty(UD108Key1)
        //                        && !string.IsNullOrEmpty(SysRowId))
        //        {
        //            //Get PalletSelection Data by Company, UD108Key1,sysRowId - params are from LPDtls object
        //            BusinessLayer BL = new BusinessLayer();
        //            List<PalletSelection> entity = BL.GetLstPalletSelectionByPKeys(Company, UD108Key1, SysRowId);
        //            if (entity != null && entity.Any())
        //            {
        //                return Request.CreateResponse(HttpStatusCode.OK, entity);
        //            }
        //            else
        //            {
        //                return Request.CreateErrorResponse(HttpStatusCode.NotFound,
        //                $"Company: {Company} And UD108Key1 : {UD108Key1} And SysRowId : {SysRowId} data not found!");
        //            }
        //        }
        //        else
        //        {
        //                return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
        //                 $"Company Or UD108Key1 Or SysRowId is Zero Or Null!");

        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
        //    }
        //}

        // POST: api/LPPalletSelection
        public HttpResponseMessage Post([FromBody] PalletSelection entity)
        {
            try
            {
                if (entity != null)
                {
                    var           json = new JavaScriptSerializer().Serialize(entity);
                    BusinessLayer BL   = new BusinessLayer();
                    string        msg  = BL.InsertLPPalletSelection(entity);
                    return(Request.CreateResponse(HttpStatusCode.OK, msg));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                       $"Data is Null!"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }