Ejemplo n.º 1
0
        public HttpResponseMessage GetBuyers()
        {
            var buyers = new Buyer_Crud().Buyer_GetAll();

            if (buyers != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, buyers));
            }

            return(Request.CreateResponse(HttpStatusCode.NoContent, buyers));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage PutBuyer(Buyer buyer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = new Buyer_Crud().Buyer_Update(buyer);

                    if (result != null || result != "")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 3
0
        public HttpResponseMessage DeleteBuyer(int Pid)
        {
            var result = new Buyer_Crud().Buyer_GetById(Pid);

            if (result.Pid == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent, result));
            }
            try
            {
                result.Pid = new Buyer_Crud().Buyer_Delete(Pid);
                if (result.Pid != 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, result));
                }
                return(Request.CreateResponse(HttpStatusCode.NoContent, result));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, result));
            }
        }
Ejemplo n.º 4
0
        // GET: api/GetBuyer/2
        public Buyer GetBuyer(int?Pid)
        {
            var buyer = new Buyer_Crud().Buyer_GetById(Pid);

            return(buyer);
        }