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.
 
 
 
 
 

72 lines
2.0 KiB

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using AMESCoreStudio.WebApi.Models.AMES;
namespace AMESCoreStudio.WebApi.Controllers.AMES
{
/// <summary>
///
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class WipInfosController : Controller
{
private readonly AMESContext _context;
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public WipInfosController(AMESContext context)
{
_context = context;
}
/// <summary>
/// 獲取產品別資料
/// </summary>
/// <returns></returns>
// GET: api/SystemInfoes
[HttpGet]
public async Task<ActionResult<IEnumerable<WipInfo>>> GetWipInfo()
{
IQueryable<WipInfo> q = _context.WipInfos;
q = q.OrderBy(p => p.WipNO);
//q = q.OrderByDescending(p => p.SystemID);
var WipInfo = await q.ToListAsync();
//return await _context.SystemInfoes.ToListAsync();
return WipInfo;
}
/// <summary>
/// 新增工單資料
/// </summary>
/// <param name="WipInfo"></param>
/// <returns></returns>
// POST: api/SystemInfoes
// To protect from overposting attacks, enable the specific properties you want to bind to, for
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
[HttpPost]
public async Task<ActionResult<WipInfo>> PostWipInfo([FromBody] WipInfo WipInfo)
{
Helper helper = new Helper(_context);
WipInfo.WipID = helper.GetIDKey("WIP_ID").Result;
WipInfo.CreateUserID = 0;
_context.WipInfos.Add(WipInfo);
await _context.SaveChangesAsync();
return CreatedAtAction("PostWipInfo", new { id = WipInfo.WipID }, WipInfo);
}
}
}