using Newtonsoft.Json;
using SelfHelpClient.BO;
using SelfHelpClient.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SelfHelpClient.BL
{
  public static class WeightBillBL
  {
    public static string ServerUrl;
    static string MethodHead = "/MainSystem/B3ClientService/Rpcs/SelfHelpRpc/";

    private static ClientRpc mRpc;
    public static ClientRpc Rpc
    {
      get
      {
        if (mRpc == null)
          mRpc = new ClientRpc(ServerUrl);
        return mRpc;
      }
    }

    public static List<ViewEntity> GetViewEntity(string idCard)
    {
      var json = Rpc.Call<string>(MethodHead + "GetViewEntity", idCard);
      return JsonConvert.DeserializeObject<List<ViewEntity>>(json);
    }

    public static WeightBill CreateWeightBill(long id)
    {
      var json = Rpc.Call<string>(MethodHead + "CreateWeightBill", id);
      return JsonConvert.DeserializeObject<WeightBill>(json);
    }

    public static WeightBill GetWeightBill(long id)
    {
      var json = Rpc.Call<string>(MethodHead + "GetWeightBill", id);
      return JsonConvert.DeserializeObject<WeightBill>(json);
    }

    public static List<WeightBill_WeightDetail> GetWeightDetail(long id)
    {
      var json = Rpc.Call<string>(MethodHead + "GetWeightDetail", id);
      return JsonConvert.DeserializeObject<List<WeightBill_WeightDetail>>(json);
    }

    public static WashCarPrint GetWashPrintEntity(long id, decimal fee)
    {
      var json = Rpc.Call<string>(MethodHead + "GetWashPrintEntity", id, fee);
      return JsonConvert.DeserializeObject<WashCarPrint>(json);
    }

    public static int? GetCarStandard(long id)
    {
      return Rpc.Call<int?>(MethodHead + "GetCarStandad", id);
    }
  }
}
