Beispiel #1
0
        public IActionResult GetCity(int kodeprov)
        {
            List <CityOutputModel> city = new List <CityOutputModel>();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Base/");
                CityInputModel param = new CityInputModel();
                param.KodeProv = kodeprov;
                JsonConvert.SerializeObject(param);
                var cityTask = client.PostAsJsonAsync <CityInputModel>("GetCity", param);
                cityTask.Wait();
                var results = cityTask.Result;
                if (results.IsSuccessStatusCode)
                {
                    var content = results.Content.ReadAsStringAsync();
                    CityResponseModel provinceResponse = JsonConvert.DeserializeObject <CityResponseModel>(content.Result);
                    city = provinceResponse.data.OrderBy(x => x.Kota).ToList();
                }
                else
                {
                    city = null;
                    ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                }
            }
            return(Json(city));
        }
Beispiel #2
0
        public IActionResult GetCity()
        {
            List <CityOutputModel> city = new List <CityOutputModel>();

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(BaseAPI + "Base/");
                    var provTask = client.PostAsync("GetAllCity", null);
                    provTask.Wait();
                    var results = provTask.Result;
                    if (results.IsSuccessStatusCode)
                    {
                        var content = results.Content.ReadAsStringAsync();
                        CityResponseModel cityResponse = JsonConvert.DeserializeObject <CityResponseModel>(content.Result);
                        city = cityResponse.data.OrderBy(x => x.Kota).ToList();
                    }
                    else
                    {
                        city = null;
                        ModelState.AddModelError(string.Empty, "Terjadi kesalahan server. Hubungi admin.");
                    }
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, "Terjadi kesalahan server. Hubungi admin.");
            }
            return(Ok(city));
        }
Beispiel #3
0
        public ActionResult <CityResponseModel> GetCityNew()
        {
            CityResponseModel res = new CityResponseModel();

            try
            {
                CityRepository repo = new CityRepository(db);

                var query = repo.GetAllCitiesFromTitikLokasi();

                var res2 = (from y in query
                            select new CityOuputModel
                {
                    ProvinceID = Guid.Empty,
                    CityID = Guid.Empty,
                    Kode = 0,
                    Kota = y.CityName
                }).Distinct().ToList();

                res.data     = res2;
                res.Message  = "Success get data";
                res.Response = true;
                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;
                return(res);
            }
        }
Beispiel #4
0
        public ActionResult <CityResponseModel> GetCity([FromBody] CityInputModel data)
        {
            CityResponseModel res = new CityResponseModel();

            try
            {
                CityRepository repo = new CityRepository(db);

                var query = repo.GetCities(data.KodeProv);

                var res2 = (from y in query
                            select new CityOuputModel
                {
                    ProvinceID = y.ProvinceID,
                    CityID = y.ID,
                    Kode = y.Kode,
                    Kota = y.CityName
                }).OrderBy(x => x.Kota).ToList();

                res.data     = res2;
                res.Message  = "Success get data";
                res.Response = true;
                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;
                return(res);
            }
        }
Beispiel #5
0
 private void GetCityResponse(CityResponseModel response)
 {
     if (response != null)
     {
         var profile = SL.Profile;
         if (profile == null)
         {
             return;
         }
         ProfileUpdateModel profileUpdateModel = new ProfileUpdateModel();
         profileUpdateModel.AppVersion            = profile.AppVersion;
         profileUpdateModel.City                  = response.result;
         profileUpdateModel.EmailAddress          = profile.EmailAddress;
         profileUpdateModel.isGeoEnabled          = true;
         profileUpdateModel.isNotificationEnabled = profile.isNotificationEnabled;
         profileUpdateModel.isPhoneBookEnabled    = false;
         profileUpdateModel.LocationLat           = Platform.Lat;
         profileUpdateModel.LocationLon           = Platform.Lon;
         profileUpdateModel.UserName              = profile.UserName;
         SL.Manager.UpdateProfileAsync(profileUpdateModel, null);
         //var profile = SL.Profile;
         //profile.City = response.result;
         //SL.Manager.SaveProfileAsync(profile);
     }
 }
        public CityResponseModel Citys()
        {
            // Store Customer Seleted Garage in session
            //Session["NewServiceGarageId"] = id;



            CityResponseModel model = new CityResponseModel();

            try
            {
                var       cityList  = _db.Database.SqlQuery <CityModel>("exec dbo.GetAllAvailableGaragesCitiesList").ToList();
                CityModel cityModel = null;
                foreach (var item in cityList)
                {
                    cityModel          = new CityModel();
                    cityModel.Id       = item.Id;
                    cityModel.CityName = item.CityName;

                    model.Citys.Add(cityModel);
                }
                model.Result = true;
            }
            catch (Exception ex)
            {
            }

            //return Ok(model);
            return(model);
        }
Beispiel #7
0
 // GET: /<controller>/
 public IActionResult Index()
 {
     HttpContext.Session.SetString(SessionKeyEdit, "");
     if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "")
     {
         List <CityOutputModel> City = new List <CityOutputModel>();
         if (TempData["CustomError"] != null)
         {
             ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString());
         }
         else
         {
             using (var client = new HttpClient())
             {
                 client.BaseAddress = new Uri(BaseAPI + "Base/");
                 var provTask = client.PostAsync("GetAllCity", null);
                 provTask.Wait();
                 var results = provTask.Result;
                 if (results.IsSuccessStatusCode)
                 {
                     var content = results.Content.ReadAsStringAsync();
                     CityResponseModel CityResponse = JsonConvert.DeserializeObject <CityResponseModel>(content.Result);
                     City = CityResponse.data.OrderBy(x => x.Kode).ToList();
                 }
                 else
                 {
                     City = null;
                     ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                 }
             }
         }
         return(View(City));
     }
     else
     {
         TempData["CustomError"] = "Silakan masuk sebelum menggunakan situs web.";
         //if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV")
         //{
         //	return RedirectToAction("AdminLogon", "Login");
         //}
         //else if (HttpContext.Session.GetString(Loginfrom) == "MDO")
         //{
         //	return RedirectToAction("OwnerLogon", "Login");
         //}
         //else
         //{
         //	return RedirectToAction("OwnerLogon", "Login");
         //}
         return(RedirectToAction("Logon", "Login"));
     }
 }
Beispiel #8
0
		// GET: /<controller>/
		public IActionResult Index()
		{
			HttpContext.Session.SetString(SessionKeyEdit, "");
			if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "")
			{
				List<CityOutputModel> City = new List<CityOutputModel>();
				if (TempData["CustomError"] != null)
				{
					ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString());
				}
				else
				{
					using (var client = new HttpClient())
					{
						client.BaseAddress = new Uri(BaseAPI + "Base/");
						var provTask = client.PostAsync("GetAllCity", null);
						provTask.Wait();
						var results = provTask.Result;
						if (results.IsSuccessStatusCode)
						{
							var content = results.Content.ReadAsStringAsync();
							CityResponseModel CityResponse = JsonConvert.DeserializeObject<CityResponseModel>(content.Result);
							City = CityResponse.data.OrderBy(x => x.Kode).ToList();
						}
						else
						{
							City = null;
							ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
						}
					}
				}
				return View(City);
			}
			else
			{
				TempData["CustomError"] = "Please login before using the web.";
				if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV")
				{
					return RedirectToAction("AdminLogon", "Login");
				}
				else if (HttpContext.Session.GetString(Loginfrom) == "MDO")
				{
					return RedirectToAction("OwnerLogon", "Login");
				}
				else
				{
					return RedirectToAction("BuyerLogon", "Login");
				}
				//return RedirectToAction("Logon", "Login");
			}
		}
Beispiel #9
0
        public JsonResult GetCity(DataTableAjaxPostModel model)
        {
            int filteredResultsCount = 0;
            int totalResultsCount    = 0;

            List <CityOutputModel> city = new List <CityOutputModel>();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Base/");
                var cityTask = client.PostAsync("GetAllCity", null);
                cityTask.Wait();
                var results = cityTask.Result;
                if (results.IsSuccessStatusCode)
                {
                    var content = results.Content.ReadAsStringAsync();
                    CityResponseModel cityResponse = JsonConvert.DeserializeObject <CityResponseModel>(content.Result);
                    city = cityResponse.data.OrderBy(x => x.Kode).ToList();
                }
                else
                {
                    city = null;
                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }
            }

            var result = new List <JsonCity>();

            foreach (var x in city)
            {
                result.Add(new JsonCity
                {
                    CityID = x.CityID,
                    kode   = x.Kode.ToString(),
                    city   = x.Kota.ToString()
                });
            }

            totalResultsCount = result.Count();

            return(Json(new
            {
                draw = model.draw,
                recordsTotal = totalResultsCount,
                recordsFiltered = filteredResultsCount,
                data = result
            }));
        }
        public IHttpActionResult Citys()
        {
            // Store Customer Seleted Garage in session
            //Session["NewServiceGarageId"] = id;



            CityResponseModel model = new CityResponseModel();

            try
            {
                var       cityList  = _db.Database.SqlQuery <CityModel>("exec dbo.GetAllAvailableGaragesCitiesList").ToList();
                CityModel cityModel = null;
                foreach (var item in cityList)
                {
                    cityModel          = new CityModel();
                    cityModel.Id       = item.Id;
                    cityModel.CityName = item.CityName;

                    model.Citys.Add(cityModel);
                }
                model.Result = true;
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            if (model != null)
            {
                return(Ok(model.Citys));
            }
            else
            {
                return(NotFound());
            }
        }