using BLL.API;
using Model;
using Model.APIItem;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using BLL;

namespace WebAPI.Controllers
{
    public class QuantityManagementController : ApiController
    {
        [HttpGet]
        public Model.ResponeData dayInputList(string projectId, string drawingNo, string part, string projectContent, int page, int pageSize)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {
                if (string.IsNullOrEmpty(drawingNo) || drawingNo == "null")
                {
                    drawingNo = "";
                }
                if (string.IsNullOrEmpty(part) || part == "null")
                {
                    part = "";
                }
                if (string.IsNullOrEmpty(projectContent) || projectContent == "null")
                {
                    projectContent = "";
                }
                return APIQuantityManagementService.DayInputList(projectId, drawingNo, part, projectContent, page, pageSize);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;
        }

        [HttpGet]
        public Model.ResponeData getDayInputById(string dayInputId)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {

                return APIQuantityManagementService.getDayInputById(dayInputId);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;
        }

        [HttpPost]
        public Model.ResponeData addDayInput([FromBody] DayInputItem dayInput)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {
                return APIQuantityManagementService.addDayInput(dayInput);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;
        }

        [HttpGet]
        public Model.ResponeData getDrawingNoList(string projectId)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {

                return APIQuantityManagementService.getDrawingNoList(projectId);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;

        }

        [HttpGet]
        public Model.ResponeData getTeamGroupList(string projectId)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {

                return APIQuantityManagementService.getTeamGroupList(projectId);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;

        }

        [HttpGet]
        public Model.ResponeData getPartList(string drawingId)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {

                return APIQuantityManagementService.getPartList(drawingId);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;

        }

        [HttpGet]
        public Model.ResponeData getProjectContentList(string drawingId, string part)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {

                return APIQuantityManagementService.getProjectContentList(drawingId, part);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;

        }

        [HttpGet]
        public Model.ResponeData getBase(string baseId)
        {
            Model.ResponeData respone = new ResponeData();
            try
            {

                return APIQuantityManagementService.getBase(baseId);
            }
            catch (Exception e)
            {
                respone.code = 0;
                respone.message = e.Message;
            }
            return respone;

        }
    }
}