Example #1
0
        // GET: Charge/Details/5
        public async Task <ActionResult> Details(string id)
        {
            Charge        ModelGlobal = default(Charge);
            GetChargeForm ModelLocal  = default(GetChargeForm);

            List <GetProviderForm> getproviderformList = await ProviderController.GetProviderList();

            List <GetHistoryForm> gethistoryformList = await HistoryController.GetHistoryList();

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

            foreach (var item in gethistoryformList)
            {
                item.CarName = (from b in getCarformList
                                where b.IdCar == item.IdCar
                                select b.ChassisNumber).FirstOrDefault();

                item.CarName = item.CarName + " - " + (from b in getCarformList
                                                       where b.IdCar == item.IdCar
                                                       select b.ModelName).FirstOrDefault();
            }

            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($"Charge/Get/{id}");

                if (Res.IsSuccessStatusCode)
                {
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;

                    ModelGlobal = JsonConvert.DeserializeObject <Charge>(EmpResponse);
                    ModelLocal  = AutoMapper <Charge, GetChargeForm> .AutoMap(ModelGlobal);
                }
            }


            ModelLocal.ProviderName = (from b in getproviderformList
                                       orderby b.Name
                                       where b.IdProvider == ModelLocal.IdProvider
                                       select b.Name).FirstOrDefault();

            ModelLocal.Carname = (from b in gethistoryformList
                                  orderby b.IdHistory
                                  where b.IdHistory == ModelLocal.IdHistory
                                  select b.CarName).FirstOrDefault();


            //ModelLocal.ProviderName = (from b in getproviderformList
            //                        orderby b.Text
            //                        where b.Value == ModelLocal.IdProvider.ToString()
            //                        select b.Text).FirstOrDefault();


            return(View(ModelLocal));
        }
Example #2
0
    // GET: Charge/Edit/5
    public async Task <ActionResult> Edit(string id)
    {
        EditChargeForm model = new EditChargeForm();

        model = await GetDetails(id);

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

        List <SelectListItem> getcarformList = new List <SelectListItem>();

        foreach (GetCarForm Car in carList)
        {
            getcarformList.Add(new SelectListItem {
                    Text = Car.ChassisNumber + " - " + Car.ModelName, Value = Car.IdCar.ToString()
                }
                               );
        }

        List <GetHistoryForm> historyList = await HistoryController.GetHistoryList();

        List <SelectListItem> gethistoryformList = new List <SelectListItem>();

        foreach (GetHistoryForm History in historyList)
        {
            var data = (from b in carList
                        where b.IdCar == History.IdCar
                        select b.ChassisNumber).FirstOrDefault();
            var data2 = (from b in carList
                         where b.IdCar == History.IdCar
                         select b.ModelName).FirstOrDefault();

            gethistoryformList.Add(new SelectListItem
                {
                    Selected = (History.IdHistory == Convert.ToInt32(model.HistoryId)),
                    Text     = data + " - " + data2,
                    Value    = History.IdHistory.ToString()
                });
        }

        List <GetProviderForm> providerList = await ProviderController.GetProviderList();

        List <SelectListItem> getproviderformList = new List <SelectListItem>();

        foreach (GetProviderForm Provider in providerList)
        {
            getproviderformList.Add(new SelectListItem {
                    Text = Provider.Name, Value = Provider.IdProvider.ToString()
                });
        }

        model.ProviderList = getproviderformList;
        model.HistoryList  = gethistoryformList;
        return(View(model));
    }
Example #3
0
        // GET: Charge
        public async Task <ActionResult> Index()
        {
            IEnumerable <Charge> chargeList        = null;
            List <GetChargeForm> getChargeformList = new List <GetChargeForm>();

            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("Charge/Get");

                if (Res.IsSuccessStatusCode)
                {
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;
                    chargeList = JsonConvert.DeserializeObject <List <Charge> >(EmpResponse);
                }
                foreach (Charge charge in chargeList)
                {
                    getChargeformList.Add(AutoMapper <Charge, GetChargeForm> .AutoMap(charge));
                }
            }

            List <GetProviderForm> getproviderformList = await ProviderController.GetProviderList();

            List <GetHistoryForm> gethistoryformList = await HistoryController.GetHistoryList();

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

            foreach (var item in gethistoryformList)
            {
                item.CarName = (from b in getCarformList
                                where b.IdCar == item.IdCar
                                select b.ChassisNumber).FirstOrDefault();

                item.CarName = item.CarName + " - " + (from b in getCarformList
                                                       where b.IdCar == item.IdCar
                                                       select b.ModelName).FirstOrDefault();
            }

            foreach (var item in getChargeformList)
            {
                item.ProviderName = (from b in getproviderformList
                                     orderby b.Name
                                     where b.IdProvider == item.IdProvider
                                     select b.Name).FirstOrDefault();

                item.Carname = (from b in gethistoryformList
                                orderby b.IdHistory
                                where b.IdHistory == item.IdHistory
                                select b.CarName).FirstOrDefault();
            }
            return(View(getChargeformList));
        }
Example #4
0
        // GET: Charge/Create
        public async Task <ActionResult> Create()
        {
            List <GetProviderForm> providerList = await ProviderController.GetProviderList();

            List <SelectListItem> getproviderformList = new List <SelectListItem>();

            foreach (GetProviderForm Provider in providerList)
            {
                getproviderformList.Add(new SelectListItem {
                    Text = Provider.Name, Value = Provider.IdProvider.ToString()
                });
            }

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

            List <SelectListItem> getcarformList = new List <SelectListItem>();

            foreach (GetCarForm Car in carList)
            {
                getcarformList.Add(new SelectListItem {
                    Text = Car.ChassisNumber + " - " + Car.ModelName, Value = Car.IdCar.ToString()
                });
            }

            List <GetHistoryForm> historyList = await HistoryController.GetHistoryList();

            List <SelectListItem> gethistoryformList = new List <SelectListItem>();

            foreach (GetHistoryForm History in historyList)
            {
                var data = (from b in carList
                            where b.IdCar == History.IdCar
                            select b.ChassisNumber).FirstOrDefault();
                var data2 = (from b in carList
                             where b.IdCar == History.IdCar
                             select b.ModelName).FirstOrDefault();

                gethistoryformList.Add(new SelectListItem {
                    Text = data + " - " + data2, Value = History.IdHistory.ToString()
                });
            }

            var model = new AddChargeForm
            {
                HistoryList  = gethistoryformList,
                ProviderList = getproviderformList
            };

            return(View(model));
        }
Example #5
0
// GET: Charge/Delete/5
public async Task <ActionResult> Delete(int id)
{
    Charge           ModelGlobal = default(Charge);
    DeleteChargeForm ModelLocal  = default(DeleteChargeForm);

    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($"Charge/Get/{id}");

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

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

    List <SelectListItem> getcarformList = new List <SelectListItem>();

    foreach (GetCarForm Car in carList)
    {
        getcarformList.Add(new SelectListItem {
                    Text = Car.ChassisNumber + " - " + Car.ModelName, Value = Car.IdCar.ToString()
                }
                           );
    }

    List <GetProviderForm> providerList = await ProviderController.GetProviderList();

    List <SelectListItem> getproviderformList = new List <SelectListItem>();

    foreach (GetProviderForm Provider in providerList)
    {
        getproviderformList.Add(new SelectListItem {
                    Text = Provider.Name, Value = Provider.IdProvider.ToString()
                });
    }

    List <GetHistoryForm> historyList = await HistoryController.GetHistoryList();

    List <SelectListItem> gethistoryformList = new List <SelectListItem>();

    foreach (GetHistoryForm History in historyList)
    {
        var data = (from b in carList
                    where b.IdCar == History.IdCar
                    select b.ChassisNumber).FirstOrDefault();
        var data2 = (from b in carList
                     where b.IdCar == History.IdCar
                     select b.ModelName).FirstOrDefault();

        gethistoryformList.Add(new SelectListItem
                {
                    Selected = (History.IdHistory == ModelLocal.IdHistory),
                    Text     = data + " - " + data2,
                    Value    = History.IdHistory.ToString()
                });
    }



    ModelLocal.HistoryName = (from b in gethistoryformList
                              where b.Value == ModelLocal.IdHistory.ToString()
                              select b.Text).FirstOrDefault();

    ModelLocal.ProviderName = (from b in getproviderformList
                               where b.Value == ModelLocal.IdProvider.ToString()
                               select b.Text).FirstOrDefault();

    return(View(ModelLocal));
}