Example #1
0
        public IHttpActionResult GetAllSuppliers()
        {
            // declare and initialize error variable to accept the error from Repo
            string error = "";

            // get the list from supplierRepo and will insert the error if there is one
            List <SupplierModel> sms = SupplierRepo.GetAllSuppliers(out error);

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