Exemplo n.º 1
0
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            IHttpActionResult      result     = null;
            LoyalityService        service    = new LoyalityService();
            IEnumerable <Loyality> loyalities = service.GetLoyality();

            if (loyalities.Count() > 0)
            {
                result = Ok(loyalities);
            }
            else
            {
                result = NotFound();
            }
            return(result);
        }
Exemplo n.º 2
0
        // PUT api/<controller>/5
        public IHttpActionResult Put(Loyality loyality)
        {
            IHttpActionResult result  = null;
            LoyalityService   service = new LoyalityService();

            if (service.GetLoyality(loyality.ID) != null)
            {
                service.UpdateLoyality(loyality);
                result = Ok(loyality);
            }
            else
            {
                result = NotFound();
            }

            return(result);
        }
Exemplo n.º 3
0
        // GET api/<controller>/5
        public IHttpActionResult Get(int id)
        {
            IHttpActionResult result = null;

            LoyalityService service = new LoyalityService();

            Loyality loyality = service.GetLoyality(id);

            if (loyality != null)
            {
                result = Ok(loyality);
            }
            else
            {
                result = NotFound();
            }

            return(result);
        }
Exemplo n.º 4
0
        // DELETE api/<controller>/5
        public IHttpActionResult Delete(int id)
        {
            IHttpActionResult result  = null;
            LoyalityService   service = new LoyalityService();

            Loyality loyality = service.GetLoyality(id);

            if (loyality != null)
            {
                service.RemoveLoyality(id);

                result = Ok(true);
            }
            else
            {
                result = NotFound();
            }

            return(result);
        }