public async Task <ActionResult> GetLocalityById(int id)
        {
            //string strint = id.Trim().ToString();
            //var intid = Convert.ToInt32(strint);
            LocalityMasterModel pro = new LocalityMasterModel();

            LocalityMasterModelSingleRootObject obj = new LocalityMasterModelSingleRootObject();

            string url = GetUrl(2);

            url = url + "Localities/GetLocalityById?id=" + Convert.ToInt32(id) + "";
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage responseMessage = await client.GetAsync(url);

                if (responseMessage.IsSuccessStatusCode)
                {
                    var response = responseMessage.Content.ReadAsStringAsync().Result;
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Ignore,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };
                    obj = JsonConvert.DeserializeObject <LocalityMasterModelSingleRootObject>(response, settings);
                    pro = obj.data;
                    TempData["item"] = pro;
                }
            }
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> AddNewLocalityName(LocalityMasterModel model)
        {
            string url = GetUrl(2);

            url = url + "/Localities/AddNewLocalityName?strLocalityName=" + model.LocalityName + "&strImageUrl=" + model.ImageUrl + "";
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage responseMessage = await client.GetAsync(url);

                Response data = new Response();
                if (responseMessage.IsSuccessStatusCode)
                {
                    var response = responseMessage.Content.ReadAsStringAsync().Result;
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Ignore,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };
                    data = JsonConvert.DeserializeObject <Response>(response, settings);
                    //result = obj.data;
                    if (data.isSuccess)
                    {
                        TempData["message"] = "New Category Added Successfully!";
                    }
                    else
                    {
                        TempData["message"] = "New Category Not Added Successfully!";
                        //return RedirectToAction("Index");
                    }
                    //ViewBag.data = data;
                }
                TempData["message"] = "New Category Not Added Successfully!";
            }
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> AddNewLocalityName(FormCollection fc, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                LocalityMasterModel model = new LocalityMasterModel();
                string localityname       = fc["LocalityName"];
                string url = GetUrl(2);
                url = url + "Localities/AddNewLocalityName?localityname=" + localityname + "";

                using (HttpClient client = new HttpClient())
                {
                    HttpResponseMessage responseMessage = await client.GetAsync(url);

                    LocalityMasterModelRootObject result = new LocalityMasterModelRootObject();
                    if (responseMessage.IsSuccessStatusCode)
                    {
                        var response = responseMessage.Content.ReadAsStringAsync().Result;
                        var settings = new JsonSerializerSettings
                        {
                            NullValueHandling     = NullValueHandling.Ignore,
                            MissingMemberHandling = MissingMemberHandling.Ignore
                        };
                        result = JsonConvert.DeserializeObject <LocalityMasterModelRootObject>(response);
                        int localityId = result.data.LocalityId;
                        if (localityId > 0)
                        {
                            var allowedExtensions = new[]
                            {
                                ".Jpg", ".png", ".jpg", "jpeg", ".JPG",
                            };


                            //string imagepath = "http://103.233.79.234/Data/EverGreen_Android/LocalityPictures/";
                            model.ImageUrl = file.ToString();                               //getting complete url
                            var fileName = Path.GetFileName(file.FileName);                 //getting only file name(ex-ganesh.jpg)
                            var ext      = Path.GetExtension(file.FileName);                //getting the extension(ex-.jpg)
                            if (allowedExtensions.Contains(ext))                            //check what type of extension
                            {
                                string name   = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                                string myfile = +localityId + ext;                          //appending the name with id
                                                                                            // store the file inside ~/project folder(Img)
                                                                                            //var path = Path.Combine(imagepath, myfile);
                                string path = @"C:\inetpub\wwwroot\Data\EverGreen_Android\LocalityPictures\" + Server.HtmlEncode(myfile);
                                model.ImageUrl = path;
                                file.SaveAs(path);
                            }
                        }
                        else
                        {
                            ViewBag.message = "Please choose only Image file";
                        }
                    }
                    return(View("Index"));
                }
            }
            else
            {
                return(View("Index"));
            }
        }
        // GET: LocalityMaster
        public async Task <ActionResult> Index()
        {
            ViewBag.LoginID  = Session["LoginID"].ToString();
            ViewBag.Username = Session["Username"].ToString();
            ViewBag.Message  = "Your application Daily Activity page.";
            //return View();

            string preurl = GetUrl(2);

            preurl = preurl + "Store/GetAllStoreList";
            StoreMasterModelRootObject pobj = new StoreMasterModelRootObject();

            //List<ProductMasterModel> Prlist = new List<ProductMasterModel>();
            using (HttpClient prclient = new HttpClient())
            {
                HttpResponseMessage responseMessage = await prclient.GetAsync(preurl);

                if (responseMessage.IsSuccessStatusCode)
                {
                    var result = responseMessage.Content.ReadAsStringAsync().Result;
                    pobj = JsonConvert.DeserializeObject <StoreMasterModelRootObject>(result);
                    IList <SelectListItem> ProSelectList = new List <SelectListItem>();
                    foreach (var item in pobj.data)
                    {
                        ProSelectList.Add(new SelectListItem {
                            Text = item.StoreName, Value = item.StoreId.ToString()
                        });
                    }
                    ProSelectList.Insert(0, new SelectListItem()
                    {
                        Value = "", Text = "Select Store"
                    });
                    //ProSelectList.Insert(1, new SelectListItem() { Value = "0", Text = "All" });
                    ViewBag.StoreList = ProSelectList;
                }
            }
            LocalityMasterModel locality = (LocalityMasterModel)TempData["item"];

            return(View(locality));
        }