public async Task <ActionResult> GetStoreById(int id) { //string strint = id.Trim().ToString(); //var intid = Convert.ToInt32(strint); StoreMasterModel pro = new StoreMasterModel(); StoreMasterModelSingleRootObject obj = new StoreMasterModelSingleRootObject(); string url = GetUrl(2); url = url + "Store/GetStoreById?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 <StoreMasterModelSingleRootObject>(response, settings); pro = obj.data; TempData["item"] = pro; } } return(RedirectToAction("Index")); }
public async Task <ActionResult> AddNewStore(FormCollection fc, HttpPostedFileBase file) { if (ModelState.IsValid) { int StoreId = 0; StoreMasterModel model = new StoreMasterModel(); string storeid = fc["StoreId"]; string localityid = fc["LocalityName"]; string storename = fc["StoreName"]; string phonenumber = fc["StorePhoneNumber"]; string email = fc["StoreEmailId"]; string address = fc["StoreAddress"]; string openingtime = fc["OpeningTime"]; string closingtime = fc["ClosingTime"]; ViewBag.StoreId = Session["StoreId"].ToString(); if (storeid != "0") { StoreId = Convert.ToInt32(storeid); SavePictures(StoreId, file); } string url = GetUrl(2); url = url + "Store/AddNewStore?storeid=" + storeid + "&storename=" + storename + "&phonenumber=" + phonenumber + "&email=" + email + "&address=" + address + "&opeingtime=" + openingtime + "&closingtime=" + closingtime + "&localityid=" + localityid + ""; using (HttpClient client = new HttpClient()) { HttpResponseMessage responseMessage = await client.GetAsync(url); StoreMasterModelSingleRootObject result = new StoreMasterModelSingleRootObject(); if (responseMessage.IsSuccessStatusCode) { var response = responseMessage.Content.ReadAsStringAsync().Result; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; result = JsonConvert.DeserializeObject <StoreMasterModelSingleRootObject>(response); if (result.data.StoreId > 0) { StoreId = result.data.StoreId; SavePictures(StoreId, file); } } return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } }
// GET: StoreMaster 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 url = GetUrl(2); url = url + "Localities/GetAllLocalitiesWithOutPagging"; LocalityMasterModelRootObject obj = new LocalityMasterModelRootObject(); using (HttpClient client = new HttpClient()) { HttpResponseMessage responseMessage = await client.GetAsync(url); if (responseMessage.IsSuccessStatusCode) { var result = responseMessage.Content.ReadAsStringAsync().Result; obj = JsonConvert.DeserializeObject <LocalityMasterModelRootObject>(result); IList <SelectListItem> LSelectList = new List <SelectListItem>(); foreach (var item in obj.data) { LSelectList.Add(new SelectListItem { Text = item.LocalityName, Value = item.LocalityId.ToString() }); } LSelectList.Insert(0, new SelectListItem() { Value = "", Text = "Select Locality" }); //LSelectList.Insert(1, new SelectListItem() { Value = "0", Text = "All" }); ViewBag.LocalityList = LSelectList; } } StoreMasterModel menu = (StoreMasterModel)TempData["item"]; return(View(menu)); }
public async Task <ActionResult> AddNewStore(FormCollection fc, HttpPostedFileBase file) { if (ModelState.IsValid) { StoreMasterModel model = new StoreMasterModel(); string storename = fc["StoreName"]; string phonenumber = fc["PhoneNumber"]; string email = fc["Email"]; string address = fc["Address"]; string url = GetUrl(2); url = url + "Store/AddNewStore?storename=" + storename + "&phonenumber=" + phonenumber + "&email=" + email + "&address=" + address + ""; using (HttpClient client = new HttpClient()) { HttpResponseMessage responseMessage = await client.GetAsync(url); StoreMasterModelRootObject result = new StoreMasterModelRootObject(); if (responseMessage.IsSuccessStatusCode) { var response = responseMessage.Content.ReadAsStringAsync().Result; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; result = JsonConvert.DeserializeObject <StoreMasterModelRootObject>(response); int storeid = result.data.StoreId; if (storeid > 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 = +storeid + 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\StorePictures\" + Server.HtmlEncode(myfile); model.ImageUrl = path; file.SaveAs(path); } } else { ViewBag.message = "Please choose only Image file"; } } return(View("Index")); } } else { return(View("Index")); } }