Exemplo n.º 1
0
        public JsonResult LoadZipcode(string provinceName, string amphurName, string districtName)
        {
            var jsonResponse = new JsonResponse {
                status = false, total = 0
            };

            try
            {
                Thailand thailand = new Thailand(db);
                var      zipcode  = thailand.GetZipcode(provinceName, amphurName, districtName);
                jsonResponse = new JsonResponse()
                {
                    status = true, message = "Ok", data = zipcode
                };
            }
            catch (Exception ex)
            {
                jsonResponse = new JsonResponse()
                {
                    status = false, message = ex.Message
                };
                Log.Error(this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + " Error -> " + ex.Message);
            }
            return(Json(jsonResponse));
        }
Exemplo n.º 2
0
        public JsonResult LoadDistrict(string provinceName, string amphurName)
        {
            var jsonResponse = new JsonResponse {
                status = false, total = 0
            };

            try
            {
                Thailand thailand = new Thailand(db);
                var      entity   = thailand.GetAllDistricts(provinceName, amphurName).Select(p => new DropdownEntity()
                {
                    Id   = p.DistrictName,
                    Name = p.DistrictName
                }).ToList();
                jsonResponse = new JsonResponse()
                {
                    status = true, message = "Ok", data = entity
                };
            }
            catch (Exception ex)
            {
                jsonResponse = new JsonResponse()
                {
                    status = false, message = ex.Message
                };
                Log.Error(this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + " Error -> " + ex.Message);
            }
            return(Json(jsonResponse));
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            try
            {
                var permission = UserPermission;
                using (var db = new InternetAccountEntities())
                {
                    var area = db.Areas.Where(r => permission.Province.Contains(r.AreaCode)).ToList();

                    ViewBag.Area = area;

                    var    thailand       = new Thailand(db);
                    var    province       = thailand.GetAllProvince();
                    string selectProvince = (area != null ? area[0].AreaName : province[0].ProvinceName);
                    if (!province.Exists(p => p.ProvinceName == selectProvince))
                    {
                        selectProvince = province[0].ProvinceName;
                    }
                    if (province.Count > 0)
                    {
                        var amphur   = thailand.GetAllAmphurs(selectProvince);
                        var district = thailand.GetAllDistricts(selectProvince, amphur[0].AmphurName);
                        ViewData["_Province"] = province.Select(p => new DropdownEntity
                        {
                            Id       = p.ProvinceCode.ToString(),
                            Name     = p.ProvinceName,
                            Selected = (p.ProvinceName == selectProvince ? true : false)
                        }).ToList();
                        ViewData["_Amphur"] = amphur.Select(p => new DropdownEntity
                        {
                            Id   = p.AmphurName,
                            Name = p.AmphurName
                        }).ToList();
                        ViewData["_District"] = district.Select(p => new DropdownEntity
                        {
                            Id   = p.DistrictName,
                            Name = p.DistrictName
                        }).ToList();
                        ViewData["_Zipcode"] =
                            thailand.GetZipcode(selectProvince, amphur[0].AmphurName, district[0].DistrictName)
                            .ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + " Error -> " + ex.Message);
            }
            return(View());
        }
Exemplo n.º 4
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Thailand obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }