8 changed files with 554 additions and 31 deletions
@ -0,0 +1,146 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 條碼鎖定資料表
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class BarcodeLockController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public BarcodeLockController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
// GET: api/BarcodeLock
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<BarcodeLock>>> GetBarcodeLock() |
||||
|
{ |
||||
|
return await _context.BarcodeLocks.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
// GET: api/BarcodeLock/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<BarcodeLock>> GetBarcodeLock(int id) |
||||
|
{ |
||||
|
var barcodeLock = await _context.BarcodeLocks.FindAsync(id); |
||||
|
|
||||
|
if (barcodeLock == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return barcodeLock; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 條碼鎖定資料表 by BarCodeID
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">BarCodeID</param>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/BarcodeLock/5
|
||||
|
[HttpGet("BarCodeID/{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<BarcodeLock>>> GetBarcodeLockByBarCodeID(int id) |
||||
|
{ |
||||
|
|
||||
|
IQueryable<BarcodeLock> q = _context.BarcodeLocks; |
||||
|
q = q.Where(p => p.BarcodeID.Equals(id)); |
||||
|
var barcodelock = await q.ToListAsync(); |
||||
|
|
||||
|
if (barcodelock == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return barcodelock; |
||||
|
} |
||||
|
|
||||
|
// PUT: api/BarcodeLock/5
|
||||
|
// 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.
|
||||
|
[HttpPut("{id}")] |
||||
|
public async Task<IActionResult> PutBarcodeLock(decimal id, BarcodeLock barcodeLock) |
||||
|
{ |
||||
|
if (id != barcodeLock.BarcodeLockID) |
||||
|
{ |
||||
|
return BadRequest(); |
||||
|
} |
||||
|
|
||||
|
_context.Entry(barcodeLock).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateConcurrencyException) |
||||
|
{ |
||||
|
if (!BarcodeLockExists(id)) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
|
||||
|
// POST: api/BarcodeLock
|
||||
|
// 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<BarcodeLock>> PostBarcodeLock(BarcodeLock barcodeLock) |
||||
|
{ |
||||
|
_context.BarcodeLocks.Add(barcodeLock); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateException) |
||||
|
{ |
||||
|
if (BarcodeLockExists(barcodeLock.BarcodeLockID)) |
||||
|
{ |
||||
|
return Conflict(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return CreatedAtAction("GetBarcodeLock", new { id = barcodeLock.BarcodeLockID }, barcodeLock); |
||||
|
} |
||||
|
|
||||
|
// DELETE: api/BarcodeLock/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<BarcodeLock>> DeleteBarcodeLock(decimal id) |
||||
|
{ |
||||
|
var barcodeLock = await _context.BarcodeLocks.FindAsync(id); |
||||
|
if (barcodeLock == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.BarcodeLocks.Remove(barcodeLock); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return barcodeLock; |
||||
|
} |
||||
|
|
||||
|
private bool BarcodeLockExists(decimal id) |
||||
|
{ |
||||
|
return _context.BarcodeLocks.Any(e => e.BarcodeLockID == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,127 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 檔案用途 條碼工單資料檔
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class BarcodeWipController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public BarcodeWipController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
// GET: api/BarcodeWip
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<BarcodeWip>>> GetBarcodeWips() |
||||
|
{ |
||||
|
return await _context.BarcodeWips.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
// GET: api/BarcodeWip/5
|
||||
|
[HttpGet("{id}/{wipid}")] |
||||
|
public async Task<ActionResult<BarcodeWip>> GetBarcodeWipByTwoKey(decimal id, decimal wipid) |
||||
|
{ |
||||
|
var barcodeWip = await _context.BarcodeWips.Where(w => w.BarcodeID == id && w.WipID == wipid).FirstOrDefaultAsync(); |
||||
|
|
||||
|
if (barcodeWip == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return barcodeWip; |
||||
|
} |
||||
|
|
||||
|
// PUT: api/BarcodeWip/5
|
||||
|
// 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.
|
||||
|
[HttpPut("{id}")] |
||||
|
public async Task<IActionResult> PutBarcodeWip(decimal id, BarcodeWip barcodeWip) |
||||
|
{ |
||||
|
if (id != barcodeWip.WipID) |
||||
|
{ |
||||
|
return BadRequest(); |
||||
|
} |
||||
|
|
||||
|
_context.Entry(barcodeWip).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateConcurrencyException) |
||||
|
{ |
||||
|
if (!BarcodeWipExists(id)) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
|
||||
|
// POST: api/BarcodeWip
|
||||
|
// 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<BarcodeWip>> PostBarcodeWip(BarcodeWip barcodeWip) |
||||
|
{ |
||||
|
_context.BarcodeWips.Add(barcodeWip); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateException) |
||||
|
{ |
||||
|
if (BarcodeWipExists(barcodeWip.WipID)) |
||||
|
{ |
||||
|
return Conflict(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return CreatedAtAction("GetBarcodeWip", new { id = barcodeWip.WipID }, barcodeWip); |
||||
|
} |
||||
|
|
||||
|
// DELETE: api/BarcodeWip/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<BarcodeWip>> DeleteBarcodeWip(decimal id) |
||||
|
{ |
||||
|
var barcodeWip = await _context.BarcodeWips.FindAsync(id); |
||||
|
if (barcodeWip == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.BarcodeWips.Remove(barcodeWip); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return barcodeWip; |
||||
|
} |
||||
|
|
||||
|
private bool BarcodeWipExists(decimal id) |
||||
|
{ |
||||
|
return _context.BarcodeWips.Any(e => e.WipID == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,62 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 檔案用途 條碼工單資料檔
|
||||
|
/// </summary>
|
||||
|
[Table("BARCODE_WIP", Schema = "JHAMES")] |
||||
|
public partial class BarcodeWip |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 內部條碼ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("BARCODE_ID", TypeName = "NUMBER")] |
||||
|
[DataMember] |
||||
|
[Display(Name = "內部條碼ID")] |
||||
|
public decimal BarcodeID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 工單ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("WIP_ID", TypeName = "NUMBER")] |
||||
|
[DataMember] |
||||
|
[Display(Name = "工單ID")] |
||||
|
public decimal WipID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立者
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "建立者")] |
||||
|
public decimal CreateUserID { get; set; } = -1; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立時間
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_DATE")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "建立時間")] |
||||
|
public DateTime CreateDate { get; set; } = DateTime.Now; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改時間
|
||||
|
/// </summary>
|
||||
|
[Column("UPDATE_DATE")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "修改時間")] |
||||
|
public DateTime UpdateDate { get; set; } = DateTime.Now; |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue