public JsonResult Create(int?id, FormCollection collection) { if (id == null || collection["name"] == null) { return(Json(new { status = "failed" }, JsonRequestBehavior.AllowGet)); } var a = collection["weight"]; int i = 0; int.TryParse(a, out i); Nullable <int> result = new Nullable <int>(i); problem newProblem = new problem { name = collection["name"], description = collection["description"], weight = result, inputDescription = collection["inputdescription"], outputDescription = collection["outputdescription"], sampleInput = collection["sampleinput"], sampleOutput = collection["sampleoutput"] }; db.problem.Add(newProblem); db.SaveChanges(); problems newConnection = new problems { problemId = db.problem.Max(x => x.id), assignmentId = Convert.ToInt32(id) }; db.problems.Add(newConnection); db.SaveChanges(); int prblmId = db.problem.Max(x => x.id); return(Json(new { status = "SuccessAdd", problemId = prblmId }, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteProblem(string id) { if (id == null) { return(Json(new { status = "failed" }, JsonRequestBehavior.AllowGet)); } int prbId = Convert.ToInt32(id); problem prob = db.problem.Find(prbId); problems prob2 = problmService.GetConnectionById(prbId); int aId = prob2.id; //because errors problems probs = db.problems.Find(aId); List <testcase> cases = problmService.getTestCasesOfProblem(prbId); foreach (var item in cases) { db.testcaseOutput.RemoveRange(db.testcaseOutput.Where(b => b.testcaseId == item.id)); } foreach (var item in cases) { int bId = item.id; testcase tst = db.testcase.Find(bId); db.testcase.Remove(tst); } db.testcases.RemoveRange(db.testcases.Where(b => b.problemId == prbId)); List <clarification> clars = clarificationService.getClarificationsOfProblem(prbId); foreach (var item in clars) { db.clarificationAnswer.RemoveRange(db.clarificationAnswer.Where(b => b.clarificationId == item.id)); } foreach (var item in clars) { int cId = item.id; clarification clr = db.clarification.Find(cId); db.clarification.Remove(clr); } db.clarifications.RemoveRange(db.clarifications.Where(b => b.problemId == prbId)); db.problem.Remove(prob); db.problems.Remove(probs); db.SaveChanges(); return(Json(new { status = "successRemove" }, JsonRequestBehavior.AllowGet)); }
movement(right, left, down, up, ref endlunchTime, foodexitTime, ref reverseend, ref sleepTime, ref way, NumbersCreater, problems, snakeobjects, ref food);
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetProblemsData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "Diagnosis"; DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(); //DataTable dtValidation = new DataTable(); //dtValidation = CreateValidationDataTable("xclinicalvalidations"); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <problems> objclinical = new List <problems>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "departmentid", parameters["api_departmentid"].ToString() } }; JObject jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/problems", dirlst); JToken jtobj = jobj["problems"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } objclinical = jtobj.ToObject <List <problems> >(); List <problems> objclinical1 = new List <problems>(); problems objproblems = new problems(); foreach (var item in objclinical) { if (item.Events != null) { item.Source = item.Events[0].Source; item.Status = item.Events[0].Status; item.Eventtype = item.Events[0].Eventtype; item.Startdate = item.Events[0].Startdate; item.CreatedDate = item.Events[0].CreatedDate; item.OnSetDate = item.Events[0].OnSetDate; item.Laterality = item.Events[0].Laterality; item.Note = item.Events[0].Note; item.Eventcount = item.Events.Count().ToString(); } } // int count = 0; //Diagnoses records foreach (var item in objclinical) { if (item.Events != null && item.Events[0].Diagnoses != null && item.Events[0].Diagnoses.Count() > 0) { objproblems = new problems(); objproblems.Source = item.Events[0].Source; objproblems.Status = item.Events[0].Status; objproblems.Eventtype = item.Events[0].Eventtype; objproblems.Startdate = item.Events[0].Startdate; objproblems.CreatedDate = item.Events[0].CreatedDate; objproblems.OnSetDate = item.Events[0].OnSetDate; objproblems.Laterality = item.Events[0].Laterality; objproblems.Note = item.Events[0].Note; objproblems.Eventcount = item.Events.Count().ToString(); objproblems.Codeset = item.Events[0].Diagnoses[0].Codeset; objproblems.Code = item.Events[0].Diagnoses[0].Code; objproblems.Name = item.Events[0].Diagnoses[0].Name; objproblems.LastModifiedBy = item.LastModifiedBy; objproblems.LastModifiedDateTime = item.LastModifiedDateTime; objclinical1.Add(objproblems); } } if (objclinical1.Count() > 0) { objclinical.AddRange(objclinical1); } } //} dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objclinical); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["codeset"].ColumnName = "codesystemid"; dtClinicaldata.Columns["name"].ColumnName = "problem"; } string strstartdate = string.Empty; foreach (DataRow dr in dtClinicaldata.Rows) { dr["patientid"] = parameters["patientid"].ToString(); //dr["lifecycle"] = "CHRONIC"; //set hard coded lifecycle as per api documention mentioned like:The status of this problem event: CHRONIC or ACUTE //strstartdate = ""; //if (!string.IsNullOrEmpty(dr["startdate"].ToString())) //{ // strstartdate = dr["startdate"].ToString(); // if (!string.IsNullOrEmpty(strstartdate)) // { // dr["daterecorded"] = strstartdate; // } // else // { // dr["daterecorded"] = DateTime.Now.ToString(); // } //} } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }