9 changed files with 345 additions and 62 deletions
@ -0,0 +1,116 @@ |
|||||
|
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; |
||||
|
using AMESCoreStudio.WebApi.DTO.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using AMESCoreStudio.WebApi.Enum; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 解除綁定出貨序號箱號資料檔
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class UnbindExtraBarcodeController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public UnbindExtraBarcodeController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<UnbindExtraBarcode>>> GetUnbindExtraBarcode() |
||||
|
{ |
||||
|
return await _context.UnbindExtraBarcodes.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<UnbindExtraBarcode>> GetUnbindExtraBarcode(int id) |
||||
|
{ |
||||
|
var unbindExtraBarcode = await _context.UnbindExtraBarcodes.FindAsync(id); |
||||
|
|
||||
|
if (unbindExtraBarcode == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return unbindExtraBarcode; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新解除綁定出貨序號箱號資料檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="unbindExtraBarcode"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPut] |
||||
|
public async Task<ResultModel<UnbindExtraBarcode>> PutUnbindExtraBarcode(UnbindExtraBarcode unbindExtraBarcode) |
||||
|
{ |
||||
|
ResultModel<UnbindExtraBarcode> result = new ResultModel<UnbindExtraBarcode>(); |
||||
|
_context.Entry(unbindExtraBarcode).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增解除綁定出貨序號箱號資料檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="unbindExtraBarcode"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<UnbindExtraBarcode>> PostUnbindExtraBarcode(UnbindExtraBarcode unbindExtraBarcode) |
||||
|
{ |
||||
|
ResultModel<UnbindExtraBarcode> result = new ResultModel<UnbindExtraBarcode>(); |
||||
|
Helper helper = new Helper(_context); |
||||
|
unbindExtraBarcode.UnbindBarcodeId = helper.GetIDKey("UNBIND_BARCODE_ID").Result; |
||||
|
_context.UnbindExtraBarcodes.Add(unbindExtraBarcode); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// DELETE: api/FqcItem/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<UnbindExtraBarcode>> DeleteUnbindExtraBarcode(int id) |
||||
|
{ |
||||
|
var unbindExtraBarcode = await _context.UnbindExtraBarcodes.FindAsync(id); |
||||
|
if (unbindExtraBarcode == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.UnbindExtraBarcodes.Remove(unbindExtraBarcode); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return unbindExtraBarcode; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 解除綁定出貨序號箱號資料檔
|
||||
|
/// </summary>
|
||||
|
[Table("UNBIND_EXTRA_BARCODE", Schema = "JHAMES")] |
||||
|
public partial class UnbindExtraBarcode |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 解除綁定ID
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("UNBIND_BARCODE_ID")] |
||||
|
[DataMember] |
||||
|
public int UnbindBarcodeId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 起始生產條碼
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "起始生產條碼")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Column("START_BARCODE_NO")] |
||||
|
[StringLength(30)] |
||||
|
[DataMember] |
||||
|
public string StartBarcodeNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 結束生產條碼
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "結束生產條碼")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Column("END_BARCODE_NO")] |
||||
|
[StringLength(30)] |
||||
|
[DataMember] |
||||
|
public string EndBarcodeNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 解除綁定備註
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "解除綁定備註")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Column("UNBIND_REASON")] |
||||
|
[StringLength(100)] |
||||
|
[DataMember] |
||||
|
public string UnbindReason { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立UserID
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[Required] |
||||
|
[DataMember] |
||||
|
public int CreateUserID { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立日期
|
||||
|
/// </summary>
|
||||
|
[Required] |
||||
|
[Column("CREATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime CreateDate { get; set; } = DateTime.Now; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue