Ejemplo n.º 1
0
        public async System.Threading.Tasks.Task <ActionResult> Index(TravelRequestHelper model)
        {
            // string Baseurl = "http://localhost:51687/";
            string Baseurl = "http://10.85.40.68:90/";

            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res = await client.GetAsync("api/Employee/" + model.employee_info.code);

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    model.employee_info = JsonConvert.DeserializeObject <tb_m_employee>(EmpResponse);
                }

                //returning the employee list to view
                //model.employee_info = EmpInfo;
            }
            ViewBag.Username = model.employee_info.name;
            return(View(model));
        }
Ejemplo n.º 2
0
        // GET: SettlementList
        public async Task <ActionResult> Index(TravelRequestHelper model)
        {
            string Baseurl = "http://10.85.40.68:90/";

            ViewBag.Employee = model.employee_info;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);
                List <vw_request_summary> ResponseList = new List <vw_request_summary>();

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage response = await client.GetAsync("api/RequestSummary/" + model.employee_info.code);

                if (response.IsSuccessStatusCode)
                {
                    var str = response.Content.ReadAsStringAsync().Result;
                    ResponseList = JsonConvert.DeserializeObject <List <vw_request_summary> >(str);
                }

                return(View(ResponseList));
            }
        }
Ejemplo n.º 3
0
        // Details: TravelStatus
        public async Task <ActionResult> Details(IEnumerable <vw_request_summary> model)
        {
            TravelRequestHelper model2 = new TravelRequestHelper();

            //model2.travel_request = model;

            return(View(model2));
        }
Ejemplo n.º 4
0
        public async System.Threading.Tasks.Task <ActionResult> Index2(TravelRequestHelper model)
        {
            //string Baseurl = "http://localhost:51687/";
            string Baseurl = "http://10.85.40.68:90/";

            model.travel_request.no_reg = Convert.ToInt32(model.employee_info.code);

            TimeSpan duration = (DateTime)model.travel_request.end_date - (DateTime)model.travel_request.start_date;

            model.travel_request.duration = duration.Days;

            ViewBag.Title = model.employee_info.code;
            //request no reg name
            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res = await client.GetAsync("api/Employee/" + model.employee_info.code);

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    model.employee_info = JsonConvert.DeserializeObject <tb_m_employee>(EmpResponse);
                }
                ViewBag.Username = model.employee_info.name;
            }
            model.travel_request.active_flag               = true;
            model.travel_request.create_date               = DateTime.Now;
            model.travel_request.status_request            = "0";
            model.travel_request.comments                  = "lel";
            model.travel_request.participants_flag         = false;
            model.travel_request.invited_by                = model.travel_request.no_reg;
            model.travel_request.multiple_destination_flag = false;

            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage response = await client.PostAsJsonAsync("api/TravelRequest", model.travel_request);
            }
            return(View(model));
        }
Ejemplo n.º 5
0
        public async System.Threading.Tasks.Task <ActionResult> Index(string model)
        {
            tb_m_employee trh = new tb_m_employee();

            if (trh != null)
            {
                trh.code = model.Trim();
            }
            TravelRequestHelper trh2 = new TravelRequestHelper();

            trh2.employee_info = trh;
            return(View(trh2));
        }
Ejemplo n.º 6
0
        // GET: TravelRequestValidation
        public async Task <ActionResult> Index(TravelRequestHelper model)
        {
            TimeSpan duration = ((DateTime)model.travel_request.end_date - (DateTime)model.travel_request.start_date);

            model.travel_request.duration = duration.Days;

            //string Baseurl = "http://*****:*****@class + "&reg=" + model.travel_request.destination_code + "&dt=" + ((model.travel_request.overseas_flag == true) ? 1 : 0).ToString());

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    EmpInfo = JsonConvert.DeserializeObject <vw_travel_allowance>(EmpResponse);
                }
                model.travel_request.allowance_meal_idr = EmpInfo.meal_allowance * Convert.ToInt32(duration.Days);
                // cek winter gak?
                ///*
                if (model.travel_request.start_date.Value.Month == 12 || model.travel_request.start_date.Value.Month == 1 || model.travel_request.start_date.Value.Month == 0)
                {
                    model.travel_request.allowance_winter = EmpInfo.winter_allowance;
                }
                else
                {
                    model.travel_request.allowance_winter = 0;
                }
                //*/
            }
            using (var client = new HttpClient())
            {
                tb_m_rate_flight EmpInfo = new tb_m_rate_flight();
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res = await client.GetAsync("api/RateFlight/" + model.travel_request.id_destination_city);

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    EmpInfo = JsonConvert.DeserializeObject <tb_m_rate_flight>(EmpResponse);
                }
                model.travel_request.allowance_ticket = (EmpInfo.economy) * 2;
            }

            using (var client = new HttpClient())
            {
                tb_m_rate_hotel EmpInfo = new tb_m_rate_hotel();
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res = await client.GetAsync("api/RateHotel?rank=" + model.employee_info.@class);

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    EmpInfo = JsonConvert.DeserializeObject <tb_m_rate_hotel>(EmpResponse);
                }
                if (model.travel_request.overseas_flag == true)
                {
                    model.travel_request.allowance_hotel = EmpInfo.overseas * Convert.ToInt32(duration.Days);
                }
                else
                {
                    model.travel_request.allowance_hotel = EmpInfo.domestik * Convert.ToInt32(duration.Days);
                }
            }

            model.travel_request.apprv_flag_lvl5       = "0";
            model.travel_request.apprv_flag_lvl1       = "0";
            model.travel_request.apprv_flag_lvl2       = "0";
            model.travel_request.apprv_flag_lvl3       = "0";
            model.travel_request.apprv_flag_lvl4       = "0";
            model.travel_request.allowance_preparation = 0;
            model.travel_request.grand_total_allowance = model.travel_request.allowance_meal_idr + model.travel_request.allowance_hotel + model.travel_request.allowance_preparation + model.travel_request.allowance_ticket + model.travel_request.allowance_winter;


            //for exep employee
            model.travel_request.exep_empolyee = false;
            return(View(model));
        }
Ejemplo n.º 7
0
        // /*
        public async Task <ActionResult> Index(TravelRequestHelper model)
        {
            //string Baseurl = "http://localhost:51687/";
            string Baseurl = "http://10.85.40.68:90/";

            ViewBag.Username = model.employee_info.name;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage response = await client.GetAsync("api/Destination/Destination_List");

                if (response.IsSuccessStatusCode)
                {
                    List <String> ResponseList = new List <String>();
                    var           str          = response.Content.ReadAsStringAsync().Result;
                    ResponseList = JsonConvert.DeserializeObject <List <String> >(str);
                    List <SelectListItem> ListItem = new List <SelectListItem>();
                    int k = 1;
                    foreach (var item in ResponseList)
                    {
                        var listItem = new SelectListItem();
                        listItem.Text  = item;
                        listItem.Value = k.ToString();
                        ListItem.Add(listItem);
                        k++;
                    }
                    ViewBag.RL = ListItem;
                }
                //ViewBag.ResponseList = new List<SelectListItem> { };
            }

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage response = await client.GetAsync("api/Purpose/");

                if (response.IsSuccessStatusCode)
                {
                    List <String> ResponseList = new List <String>();
                    var           str          = response.Content.ReadAsStringAsync().Result;
                    ResponseList = JsonConvert.DeserializeObject <List <String> >(str);
                    List <SelectListItem> ListItem = new List <SelectListItem>();
                    int k = 1;
                    foreach (var item in ResponseList)
                    {
                        var listItem = new SelectListItem();
                        listItem.Text  = item;
                        listItem.Value = item;
                        ListItem.Add(listItem);
                        k++;
                    }
                    ViewBag.RL2 = ListItem;
                }
                //ViewBag.ResponseList = new List<SelectListItem> { };
            }


            return(View(model));
        }