public IHttpActionResult GetPendingOutstandingReqs()
        {
            // declare and initialize error variable to accept the error from Repo
            string error = "";

            // get the list from outstandingreqRepo and will insert the error if there is one
            List <OutstandingReqModel> orm =
                OutstandingReqRepo.GetAllOutstandingReq(out error);

            orm = orm.Where(x => x.Status == ConOutstandingsRequisition.Status.PENDING).ToList();

            // if the erorr is not blank or the outstanding list is null
            if (error != "" || orm == null)
            {
                // if the error is 404
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "Outstanding list Not Found"));
                }
                // if the error is other one
                return(Content(HttpStatusCode.BadRequest, error));
            }
            // if there is no error
            return(Ok(orm));
        }
        public IHttpActionResult CreateOutReq(OutstandingReqModel outreq)
        {
            string error            = "";
            OutstandingReqModel orm = OutstandingReqRepo.CreateOutReq(outreq, out error);

            if (error != "" || orm == null)
            {
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(orm));
        }
        public IHttpActionResult CompleteOutstanding(RequisitionWithOutstandingModel outreq)
        {
            string error = "";
            RequisitionWithOutstandingModel orm = OutstandingReqRepo.Complete(outreq, out error);

            if (error != "" || orm == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "Outstanding Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(orm));
        }
        public IHttpActionResult UpdateOutReq(OutstandingReqModel outreq)
        {
            string error            = "";
            OutstandingReqModel orm = OutstandingReqRepo.UpdateOutReq(outreq, out error);

            if (error != "" || orm == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "Outstanding Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(orm));
        }
        public IHttpActionResult GetOutReqByReqId(int reqid)
        {
            string error            = "";
            OutstandingReqModel orm =
                OutstandingReqRepo.GetOutstandingReqByReqId(reqid, out error);

            if (error != "" || orm == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "Outstanding Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(orm));
        }
        public IHttpActionResult UpdateRequisitionCompleted(RequisitionModel po)
        {
            string error = "";

            po = RequisitionRepo.GetRequisitionByRequisitionId(po.Reqid, out error);

            // if the staff has already updated the status to "preparing"
            if (po.Status == ConRequisition.Status.COMPLETED)
            {
                return(Ok(po));
            }
            po.Status = ConRequisition.Status.COMPLETED;

            OutstandingReqModel outreqm;

            outreqm = OutstandingReqRepo.GetOutstandingReqByReqId(po.Reqid, out error);
            if (outreqm.ReqId != 0)
            {
                po.Status = ConRequisition.Status.OUTSTANDINGREQUISITION;
            }

            // updating the status
            RequisitionModel pom = RequisitionRepo.UpdateRequisition(po, out error);


            // update the locker disburement to collected

            DisbursementLockerModel dislm = LockerCollectionPointRepo.GetDisbursementLockerByReqID(po.Reqid, out error);

            dislm = LockerCollectionPointRepo.UpdateDisbursementLockerToCollected(dislm, out error);

            if (error != "" || pom == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "PO Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(pom));
        }
        public IHttpActionResult CheckInventoryStock(int outreqid)
        {
            // declare and initialize error variable to accept the error from Repo
            string error = "";

            // get the list from outstandingreqRepo and will insert the error if there is one
            bool result =
                OutstandingReqRepo.CheckInventoryStock(outreqid, out error);


            // if the erorr is not blank or the outstanding list is null
            if (error != "")
            {
                // if the error is 404
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "Outstanding list Not Found"));
                }
                // if the error is other one
                return(Content(HttpStatusCode.BadRequest, error));
            }
            // if there is no error
            return(Ok(result));
        }