using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using System.Web.Http.Description; using Warehouse.Models; namespace Warehouse.WebApi { public class tstoragelocationsController : ApiController { private whModel db = new whModel(); // GET: api/tstoragelocations public IQueryable Gettstoragelocations() { return db.tstoragelocations; } // GET: api/tstoragelocations/5 [ResponseType(typeof(tstoragelocation))] public IHttpActionResult Gettstoragelocation(int id) { tstoragelocation tstoragelocation = db.tstoragelocations.Find(id); if (tstoragelocation == null) { return NotFound(); } return Ok(tstoragelocation); } // PUT: api/tstoragelocations/5 [ResponseType(typeof(void))] public IHttpActionResult Puttstoragelocation(int id, tstoragelocation tstoragelocation) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tstoragelocation.id) { return BadRequest(); } db.Entry(tstoragelocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tstoragelocationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); } // POST: api/tstoragelocations [ResponseType(typeof(tstoragelocation))] public IHttpActionResult Posttstoragelocation(tstoragelocation tstoragelocation) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.tstoragelocations.Add(tstoragelocation); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = tstoragelocation.id }, tstoragelocation); } // DELETE: api/tstoragelocations/5 [ResponseType(typeof(tstoragelocation))] public IHttpActionResult Deletetstoragelocation(int id) { tstoragelocation tstoragelocation = db.tstoragelocations.Find(id); if (tstoragelocation == null) { return NotFound(); } db.tstoragelocations.Remove(tstoragelocation); db.SaveChanges(); return Ok(tstoragelocation); } protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); } private bool tstoragelocationExists(int id) { return db.tstoragelocations.Count(e => e.id == id) > 0; } } }