コード例 #1
0
        public ActionResult NewFacility()
        {
            var model = new NewFacilityModel();

            return(Json(new
            {
                LocationModal = RenderRazorViewToString("PartialViews/Facility_Management/_newFacilityModal", model)
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
コード例 #2
0
        public async Task <ActionResult> EditFacility(string Id)
        {
            var model   = new NewFacilityModel();
            var Baseurl = GetURL();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var apiURL = "/api/Values/GetFacilityById/" + Id;

                HttpResponseMessage Res = await client.GetAsync(apiURL);

                if (Res.IsSuccessStatusCode)
                {
                    var result = await Res.Content.ReadAsStringAsync();

                    var response = new ResponseHelper();
                    var output   = response.fixResult(result);

                    var details = JsonConvert.DeserializeObject <Facility>(output);
                    model.Id   = details.Id;
                    model.Name = details.Name;
                    if (details.Location == null)
                    {
                        model.Location = string.Empty;
                    }
                    else
                    {
                        model.Location = details.Location;
                    }
                }
            }

            return(Json(new
            {
                LocationModal = RenderRazorViewToString("PartialViews/Facility_Management/_editFacilityModal", model)
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }