130 lines
3.8 KiB
C#
130 lines
3.8 KiB
C#
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 SupplierManager.Models;
|
|
using ViewModels;
|
|
|
|
namespace SupplierManager.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class AasProjectReportReadiesController : ControllerBase
|
|
{
|
|
private readonly AgentApprovalSystemContext _context;
|
|
|
|
public AasProjectReportReadiesController(AgentApprovalSystemContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
// GET: api/AasProjectReportReadies
|
|
[HttpPost()]
|
|
public async Task<ReturnInfo> GetAasProjectReportReadies([FromBody] QueryAll_Or_Single_ProjectInfo S)
|
|
{
|
|
ReturnInfo returnInfo = new ReturnInfo();
|
|
try
|
|
{
|
|
if (S.IsAll)
|
|
{
|
|
|
|
returnInfo.isok = true;
|
|
returnInfo.response = await _context.AasProjectReportReadies.ToListAsync();
|
|
}
|
|
else
|
|
{
|
|
returnInfo.isok = true;
|
|
var a = await _context.AasProjectReportReadies.FindAsync(S.ID);
|
|
if (a != null)
|
|
{
|
|
returnInfo.response = a;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnInfo.isok = false;
|
|
returnInfo.message = ex.Message;
|
|
}
|
|
return returnInfo;
|
|
}
|
|
|
|
|
|
// PUT: api/AasProjectReportReadies/5
|
|
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
|
[HttpPost()]
|
|
public async Task<ReturnInfo> EditAasProjectReportReady(AasProjectReportReady aasProjectReportReady)
|
|
{
|
|
|
|
ReturnInfo r = new ReturnInfo();
|
|
_context.Entry(aasProjectReportReady).State = EntityState.Modified;
|
|
|
|
try
|
|
{
|
|
await _context.SaveChangesAsync();
|
|
r.isok = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
r.isok = false;
|
|
r.message = ex.Message;
|
|
}
|
|
|
|
return r;
|
|
}
|
|
|
|
// POST: api/AasProjectReportReadies
|
|
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
|
[HttpPost]
|
|
public async Task<ReturnInfo> AddAasProjectReportReady(AasProjectReportReady aasProjectReportReady)
|
|
{
|
|
ReturnInfo r = new ReturnInfo();
|
|
try
|
|
{
|
|
|
|
_context.AasProjectReportReadies.Add(aasProjectReportReady);
|
|
await _context.SaveChangesAsync();
|
|
r.isok = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
r.isok = false;
|
|
r.message = ex.Message;
|
|
}
|
|
|
|
return r;
|
|
}
|
|
|
|
// DELETE: api/AasProjectReportReadies/5
|
|
[HttpDelete("{id}")]
|
|
public async Task<ReturnInfo> DeleteAasProjectReportReady(long id)
|
|
{
|
|
ReturnInfo r = new ReturnInfo();
|
|
try
|
|
{
|
|
var aasProjectReportReady = await _context.AasProjectReportReadies.FindAsync(id);
|
|
if (aasProjectReportReady == null)
|
|
{
|
|
r.isok = false;
|
|
r.message = "找不到要删除的数据";
|
|
}
|
|
|
|
_context.AasProjectReportReadies.Remove(aasProjectReportReady);
|
|
await _context.SaveChangesAsync();
|
|
r.isok = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
r.isok = false;
|
|
r.message = ex.Message;
|
|
}
|
|
|
|
return r;
|
|
}
|
|
|
|
}
|
|
}
|