public string GetData() { string data = ""; DataTable dt = new DataTable(); dt = new Brand_Models().BindbrandData(); if (dt.Rows.Count > 0) { data = JsonConvert.SerializeObject(dt); } return(data); }
public HttpResponseMessage InsertBrandData() { string[] filename = new string[10]; string[] filepathname = new string[10]; int i = 0; HttpResponseMessage result = null; var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var docfiles = new List <string>(); foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var filenameWithHrUserId = httpRequest.Form.Get(0) + '_' + postedFile.FileName; var filePath = AppDomain.CurrentDomain.BaseDirectory + @"Images\" + filenameWithHrUserId; //string filePath = HttpContext.Current.Server.MapPath("/StudentImage/") + filenameWithHrUserId; //string filePath = Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), postedFile.FileName)); postedFile.SaveAs(filePath); docfiles.Add(filePath); filename[i] = Convert.ToString(filenameWithHrUserId); filepathname[i] = Convert.ToString(filePath); i = i + 1; } result = Request.CreateResponse(HttpStatusCode.Created, docfiles); var BrandName = httpRequest.Form.Get(0); var SearchKeyword = httpRequest.Form.Get(1); var MetaDescription = httpRequest.Form.Get(2); var Active = httpRequest.Form.Get(3); string msg = ""; msg = new Brand_Models().InsertBrandIntoDB(filename[0], filepathname[0], BrandName, SearchKeyword, MetaDescription, Active); if (msg != "") { result = Request.CreateResponse(JsonConvert.SerializeObject(msg)); } //return data; } else { result = Request.CreateResponse(HttpStatusCode.BadRequest); } return(result); }