// GET: History/Delete/5
public async Task <ActionResult> Delete(int id)
{
    History           ModelGlobal = default(History);
    DeleteHistoryForm ModelLocal  = default(DeleteHistoryForm);

    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri(Baseurl);
        client.DefaultRequestHeaders.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        HttpResponseMessage Res = await client.GetAsync($"History/Get/{id}");

        if (Res.IsSuccessStatusCode)
        {
            var EmpResponse = Res.Content.ReadAsStringAsync().Result;
            ModelGlobal = JsonConvert.DeserializeObject <History>(EmpResponse);
            ModelLocal  = AutoMapper <History, DeleteHistoryForm> .AutoMap(ModelGlobal);
        }
    }


    List <GetCarForm> getcarformList = await CarController.GetCarList();

    List <GetSellerForm> getsellerformList = await SellerController.GetSellerList();

    List <GetBuyerForm> getbuyerformList = await BuyerController.GetBuyerList();

    var data = (from b in getcarformList
                where b.IdCar == ModelLocal.IdCar
                select b.ModelName).FirstOrDefault();

    var data2 = (from b in getcarformList
                 where b.IdCar == ModelLocal.IdCar
                 select b.ChassisNumber).FirstOrDefault();

    ModelLocal.CarName = data + " - " + data2;

    data = (from b in getsellerformList
            where b.IdSeller == ModelLocal.IdSeller
            select b.Name).FirstOrDefault();

    ModelLocal.SellerName = data;

    data = (from b in getbuyerformList
            where b.IdBuyer == ModelLocal.IdBuyer
            select b.FirstName).FirstOrDefault();
    data2 = (from b in getbuyerformList
             where b.IdBuyer == ModelLocal.IdBuyer
             select b.LastName).FirstOrDefault();

    ModelLocal.BuyerName = data + ' ' + data2;

    return(View(ModelLocal));
}
        // GET: History
        public async Task <ActionResult> Index()
        {
            IEnumerable <History> historyList        = null;
            List <GetHistoryForm> getHistoryformList = new List <GetHistoryForm>();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage Res = await client.GetAsync("History/Get");

                if (Res.IsSuccessStatusCode)
                {
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;
                    historyList = JsonConvert.DeserializeObject <List <History> >(EmpResponse);
                }
                foreach (History History in historyList)
                {
                    getHistoryformList.Add(AutoMapper <History, GetHistoryForm> .AutoMap(History));
                }
            }

            List <GetCarForm> getcarformList = await CarController.GetCarList();

            List <GetSellerForm> getsellerformList = await SellerController.GetSellerList();

            List <GetBuyerForm> getbuyerformList = await BuyerController.GetBuyerList();


            foreach (var item in getHistoryformList)
            {
                var data = (from b in getcarformList
                            where b.IdCar == item.IdCar
                            select b.ModelName).FirstOrDefault();

                var data2 = (from b in getcarformList
                             where b.IdCar == item.IdCar
                             select b.ChassisNumber).FirstOrDefault();

                item.CarName = data + " - " + data2;
            }

            foreach (var item in getHistoryformList)
            {
                var data = (from b in getsellerformList
                            where b.IdSeller == item.IdSeller
                            select b.Name).FirstOrDefault();

                item.SellerName = data;
            }

            foreach (var item in getHistoryformList)
            {
                var data1 = (from b in getbuyerformList
                             where b.IdBuyer == item.IdBuyer
                             select b.FirstName).FirstOrDefault();
                var data2 = (from b in getbuyerformList
                             where b.IdBuyer == item.IdBuyer
                             select b.LastName).FirstOrDefault();

                item.BuyerName = data1 + ' ' + data2;
            }



            return(View(getHistoryformList));
        }