Ejemplo n.º 1
0
        public IHttpActionResult GetFactoryByID(int id)
        {
            MesFactory factory = new MesFactory {
                factory_id = id
            };

            factory = factoryRes.Get(factory);
            if (factory == null)
            {
                return(NotFound());
            }
            return(Ok(factory));
        }
Ejemplo n.º 2
0
 public IHttpActionResult PutFactory(MesFactory factory)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         if (!factoryRes.Update(factory))
         {
             return(NotFound());
         }
         return(Ok(factory));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Ejemplo n.º 3
0
 public IHttpActionResult PostFactory(MesFactory factory)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         factory = factoryRes.Create(factory);
         string apiname = WebApiConfig.DEFAULT_ROUTE_NAME;
         var    respone = this.Request.CreateResponse <MesFactory>(HttpStatusCode.Created, factory);
         string uri     = Url.Link(apiname, new { id = factory.factory_id });
         respone.Headers.Location = new Uri(uri);
         return(Ok(factory));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Ejemplo n.º 4
0
 public IHttpActionResult DeleteFactory(int id)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         MesFactory control = new MesFactory {
             factory_id = id
         };
         control = factoryRes.Get(control);
         if (control == null)
         {
             throw new HttpResponseException(HttpStatusCode.NotFound);
         }
         factoryRes.Remove(id);
         return(Ok("Deleted factory!"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }