public ActionResult LoadCategories() { BrjostagjofDBDataContext db = new BrjostagjofDBDataContext(); var result = from c in db.Categories orderby c.category_name ascending select new { categoryID = c.ID, categoryName = c.category_name }; return Json(result, JsonRequestBehavior.AllowGet); }
public JsonResult GetChartData2(string chartID) { Dictionary<int, int?> pointDict = new Dictionary<int, int?>(); if (chartID.ToLower() != "null") { int id = int.Parse(chartID); BrjostagjofDBDataContext db = new BrjostagjofDBDataContext(); var result = from c in db.Timelines where c.chartID == id orderby c.x ascending select new { x = c.x, y1 = c.y1, y2 = c.y2 }; foreach (var point in result) { pointDict.Add(point.x, point.y2); } } else { pointDict.Add(0, 0); } return Json(pointDict.ToArray(), JsonRequestBehavior.AllowGet); }
public JsonResult GetTableData(string chartID) { dynamic result; BrjostagjofDBDataContext db = new BrjostagjofDBDataContext(); if (chartID.ToLower() != "null") { int id = int.Parse(chartID); result = from c in db.Timelines where c.chartID == id orderby c.x ascending select new { x = c.x, y1 = c.y1, y2 = c.y2 }; } else { result = //from c in db.Timelines new { x = 0, y1 = 0, y2 = 0 }; } return Json(result, JsonRequestBehavior.AllowGet); }
public JsonResult CreateTimelineData(string chartID,string x, string y1, string y2) { BrjostagjofDBDataContext db = new BrjostagjofDBDataContext(); var uName = User.Identity.Name; var uID = monster.getUserIDByName(uName); Timeline t = new Timeline(); if (ModelState.IsValid) { if (chartID != "null") { t.chartID = int.Parse(chartID); } else { t.chartID = monster.getChartIDSequence(); } t.x = int.Parse(x); t.y1 = int.Parse(y1); if (!string.IsNullOrEmpty(y2)) t.y2 = int.Parse(y2); else t.y2 = 0; t.created_by = uID; t.created_date = DateTime.Now; t.userID = uID; monster.addTimelineData(t); } var result = new { x = x, y1 = y1, y2 = y2 }; //var userID = monster.getUserIDByName(uName); // Fetching the user's id //var result = monster.getDataByUserID(userID); return Json(result,JsonRequestBehavior.AllowGet); }