71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Net.Http;
|
|||
|
using System.Web.Http;
|
|||
|
using Weee.Models;
|
|||
|
using Weee.Service;
|
|||
|
|
|||
|
namespace Weee.Controllers.Api.RiskAssmt
|
|||
|
{
|
|||
|
public class ItemPurchaseController : ApiControllerBase
|
|||
|
{
|
|||
|
private readonly ItemPurchaseDataService service;
|
|||
|
private readonly MaterialC3EmissionDataService service2;
|
|||
|
|
|||
|
public ItemPurchaseController(ItemPurchaseDataService d
|
|||
|
, MaterialC3EmissionDataService d2 ) : base(d)
|
|||
|
{
|
|||
|
service = d;
|
|||
|
this.service2 = d2;
|
|||
|
}
|
|||
|
|
|||
|
[Route("api/ItemPurchase/GetByLcaId/{LCAID}")]
|
|||
|
[HttpGet]
|
|||
|
//[Filter.ApiMultilanguage]disable obsolete warning, not sure OK or not
|
|||
|
public object GetByLcaId(int LCAID, int page = 1, string search = "", int pagesize = 15)
|
|||
|
{
|
|||
|
//var type = service.GetLCAType(LCAID);
|
|||
|
var query = service.GetList(LCAID);
|
|||
|
var qry2 = service2.MaterialNoLst(LCAID);
|
|||
|
|
|||
|
object ret= new
|
|||
|
{
|
|||
|
Purchases = query.ToList(),
|
|||
|
MaterialNoLst = qry2//.ToList()
|
|||
|
//OptionsOne = gwpOptions,
|
|||
|
//OptionsTwo = parameterservice.GetNonYearlyParameterOptions(Categories.Refrigerant),
|
|||
|
//SheetHeader = service.GetSheetHeader(LCAID, Categories.Refrigerant)
|
|||
|
};
|
|||
|
return ret;
|
|||
|
}
|
|||
|
|
|||
|
[Route("api/ItemPurchase/Sync/{LCAID}")]
|
|||
|
[HttpPost]
|
|||
|
public IHttpActionResult Sync(int LCAID)
|
|||
|
{
|
|||
|
service.Sync(LCAID);
|
|||
|
|
|||
|
return Ok();
|
|||
|
}
|
|||
|
[Route("api/ItemPurchase/Save/{LCAID}/{id}")]
|
|||
|
[HttpPost]
|
|||
|
public object Save(int LCAID, int id, LCARiskAssmtSurveyForm_ItemPurchase ToBeSave)
|
|||
|
{
|
|||
|
if (!ModelState.IsValid) { return BadRequest(); }
|
|||
|
if (id != ToBeSave.ID || LCAID != ToBeSave.LCAID) { return BadRequest(); }
|
|||
|
service.Save(ToBeSave);
|
|||
|
return ToBeSave;
|
|||
|
}
|
|||
|
|
|||
|
[Route("api/ItemPurchase/Delete/{ID}")]
|
|||
|
[HttpDelete]
|
|||
|
public IHttpActionResult Delete(int ID)
|
|||
|
{
|
|||
|
service.Delete(ID);
|
|||
|
return Ok();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|