92 lines
3.1 KiB
C#
92 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using Weee.Models;
|
|
using Weee.Service;
|
|
using Weee.Filter;
|
|
using System.Security.Claims;
|
|
|
|
namespace Weee.Controllers
|
|
{
|
|
public class MaterialC3EmissionController : ApiControllerBase
|
|
{
|
|
private readonly MaterialC3EmissionDataService service;
|
|
|
|
public MaterialC3EmissionController(MaterialC3EmissionDataService d) : base(d)
|
|
{
|
|
service = d;
|
|
}
|
|
|
|
[Route("api/MaterialC3Emission/GetByLcaId/{LCAID}")]
|
|
//[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);
|
|
|
|
return new
|
|
{
|
|
Materials = query.ToList(),
|
|
//OptionsOne = gwpOptions,
|
|
//OptionsTwo = parameterservice.GetNonYearlyParameterOptions(Categories.Refrigerant),
|
|
//SheetHeader = service.GetSheetHeader(LCAID, Categories.Refrigerant)
|
|
};
|
|
}
|
|
|
|
[Route("api/MaterialC3Emission/GetByLcaIdMaterialNo/{LCAID}/{materialNo}")]
|
|
[HttpPost]
|
|
//[Filter.ApiMultilanguage]disable obsolete warning, not sure OK or not
|
|
public object GetByLcaIdMaterialNo(int LCAID, string materialNo)
|
|
{
|
|
//var type = service.GetLCAType(LCAID);
|
|
var qry = service.GetByLcaIdMaterialNo(LCAID, materialNo);
|
|
|
|
return qry; /* new
|
|
{
|
|
Materials = query.ToList(),
|
|
//OptionsOne = gwpOptions,
|
|
//OptionsTwo = parameterservice.GetNonYearlyParameterOptions(Categories.Refrigerant),
|
|
//SheetHeader = service.GetSheetHeader(LCAID, Categories.Refrigerant)
|
|
};*/
|
|
}
|
|
|
|
[Route("api/MaterialC3Emission/MaterialNoLst/{LCAID}")]
|
|
//[Filter.ApiMultilanguage]disable obsolete warning, not sure OK or not
|
|
public Dictionary<string, string> MaterialNoLst(int LCAID)
|
|
{
|
|
//var type = service.GetLCAType(LCAID);
|
|
var query = service.MaterialNoLst(LCAID);
|
|
|
|
return query;
|
|
}
|
|
|
|
[Route("api/MaterialC3Emission/Save/{LCAID}/{id}")]
|
|
[HttpPost]
|
|
public object Save(int LCAID, int id, LCARiskAssmtSurveyForm_MaterialC3Emission ToBeSave)
|
|
{
|
|
try {
|
|
if (!ModelState.IsValid) { return BadRequest(); }
|
|
if (id != ToBeSave.ID || LCAID != ToBeSave.LCAID) { return BadRequest(); }
|
|
service.Save(ToBeSave);
|
|
return ToBeSave;
|
|
}
|
|
catch(Exception ex) {
|
|
log.Error(ex);
|
|
log.Error(CScommon.Exceptions.inner(ex));
|
|
log.Error(ex.StackTrace);
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
[Route("api/MaterialC3Emission/Delete/{ID}")]
|
|
[HttpDelete]
|
|
public IHttpActionResult Delete(int ID)
|
|
{
|
|
service.Delete(ID);
|
|
return Ok();
|
|
}
|
|
}
|
|
} |