Advertisement
afterlife88

blabla

Sep 20th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Http;
  6. using System.Web.Http;
  7. using RestApiConfiguration.Data;
  8. using RestApiConfiguration.Data.Repository;
  9.  
  10. namespace RestApiConfiguration.Controllers
  11. {
  12.     public class ConfigurationController : ApiController
  13.     {
  14.         private readonly ServiceCfg _service;
  15.  
  16.         public ConfigurationController()
  17.         {
  18.           //  _cfgFactory = new ConfigFactory();
  19.             _service = new ServiceCfg();
  20.         }
  21.  
  22.         public IHttpActionResult GetAll()
  23.         {
  24.             var services = _service.Repository.Get();
  25.             return Ok(services);
  26.         }
  27.  
  28.         public IHttpActionResult Get(string id)
  29.         {
  30.             var config = _service.Repository.Get(id);
  31.             return Ok(config);
  32.         }
  33.         [Route("configuration/cfgcreate}")]
  34.         public IHttpActionResult Post([FromBody] ConfigurationEntity cfgModel)
  35.         {
  36.             var service = _service.Repository.Insert(cfgModel);
  37.             return Created($"http://localhost:6348/api/Configuration/{service.ConfigName}", service.ConfigName);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement