旧版报表、仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

118 lines
3.2 KiB

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<tstoragelocation> 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;
}
}
}