public HttpResponseMessage SaveCategory() { 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 CategoryName = httpRequest.Form.Get(0); var IsParentMenuId = httpRequest.Form.Get(1); var ActiveOnPortal = httpRequest.Form.Get(2); string msg = ""; msg = new Category_Models().CategorySave(filename[0], filepathname[0], CategoryName, IsParentMenuId, ActiveOnPortal); if (msg != "") { result = Request.CreateResponse(JsonConvert.SerializeObject(msg)); } //return data; } else { result = Request.CreateResponse(HttpStatusCode.BadRequest); } return(result); }
public IEnumerable <MenuItem> BindMenuItem() { List <MenuItem> MenuList = new List <MenuItem>(); try { DataTable Menudt = new DataTable(); Menudt = new Category_Models().GetCategorywithSubCategory(); // Menudt = new login().BindMenu(UserId); if (Menudt.Rows.Count > 0) { for (int i = 0; i < Menudt.Rows.Count; i++) { string parentId = Menudt.Rows[i]["IsParentId"].ToString(); if (parentId == "0") { MenuList.Add(new MenuItem() { Value = Convert.ToString(Menudt.Rows[i]["CategoryId"]), text = Convert.ToString(Menudt.Rows[i]["CategoryName"]), ParentMenuId = Convert.ToString(Menudt.Rows[i]["IsParentId"]), filename = Convert.ToString(Menudt.Rows[i]["filename"]), Description = Convert.ToString(Menudt.Rows[i]["Description"]), filePath = Convert.ToString(Menudt.Rows[i]["filePath"]), ActiveOnPortal = Convert.ToString(Menudt.Rows[i]["ActiveOnPortal"]), items = BindChildMenu(Menudt, Convert.ToString(Menudt.Rows[i]["CategoryId"])) }); } } } } catch { } finally { } return(MenuList); }