コード例 #1
0
        // POST: api/FGReduce
        public HttpResponseMessage Post([FromBody] FGReduceLotDetails fgReduceLotDetails)
        {
            // Validate input
            if (fgReduceLotDetails == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.OK, "JSON object Empty !"));
            }

            if (string.IsNullOrEmpty(fgReduceLotDetails.Company))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.OK, "Company is Empty !"));
            }

            if (string.IsNullOrEmpty(fgReduceLotDetails.LotNum))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.OK, "Lot Num is Empty !"));
            }

            if (string.IsNullOrEmpty(fgReduceLotDetails.PartNum))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.OK, "Part Num is Empty !"));
                //throw new Exception("Part Num is Empty !");
            }


            try
            {
                if (fgReduceLotDetails != null)
                {
                    BusinessLayer BL  = new BusinessLayer();
                    string        msg = BL.UpdateFGReduce(fgReduceLotDetails);
                    return(Request.CreateErrorResponse(HttpStatusCode.OK, msg));
                }
                else
                {
                    throw new Exception("fgReduceLotDetails is empty !");
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
コード例 #2
0
        public HttpResponseMessage Get(string Company, string LotNum)
        {
            try
            {
                BusinessLayer      BL = new BusinessLayer();
                FGReduceLotDetails fgReduceLotDetails = BL.CheckFGReduceLotNum(Company, LotNum);

                if (fgReduceLotDetails.Company != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, fgReduceLotDetails));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                       $"LotNum {LotNum} row not found on the Company {Company}!"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message.ToString()));
            }
        }