public IHttpActionResult GetLocation(int id)
        {
            ILocationBS bs       = DIFactoryDesigntime.GetInstance <ILocationBS>();
            Location    location = bs.GetLocationsById(id);

            if (location == null)
            {
                return(NotFound());
            }

            return(Ok(location));
        }
        public IHttpActionResult PostLocation(Location location)
        {
            ModelState.Remove("location.Id");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ILocationBS bs = DIFactoryDesigntime.GetInstance <ILocationBS>();

            bs.AddLocations(location);

            return(CreatedAtRoute("DefaultApi", new { id = location.Id }, location));
        }
        public IHttpActionResult PutLocation(int id, Location location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != location.Id)
            {
                return(BadRequest());
            }

            ILocationBS bs = DIFactoryDesigntime.GetInstance <ILocationBS>();

            bs.UpdateLocations(location);


            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#4
0
 public LocationController(ILocationBS Location, IConfiguration conf, IHostingEnvironment _env) : base(conf)
 {
     _conf = conf;
     lBS   = Location;
 }
        // GET: api/Locations
        public IQueryable <Location> GetLocations()
        {
            ILocationBS bs = DIFactoryDesigntime.GetInstance <ILocationBS>();

            return(bs.GetLocations());
        }