public ActionResult SaveDatabase(int[] IDs) { if (IDs != null) { //var countOfRows = db.WTests.Count(); //var lastRow = db.WTests.Skip(countOfRows - 1).FirstOrDefault(); // var last = db.WTests.LastOrDefault(); Wordutopia Wt = new Wordutopia(); for (int j = 0; j < IDs.Length; j++) { var id = IDs[j]; var r = (from t in db.Wordutopias where t.WordID == id select t).FirstOrDefault(); Wt.Word = r.Word; Wt.Definition = r.Definition; Wt.Appearance = r.Appearance; Wt.AdditionInfo = r.AdditionInfo; Wt.FWUserID = userid; //Wr.FWuserid=Session["userID"] Wt.Hint = r.Hint; Wt.Phrase = r.Phrase; db.Wordutopias.Add(Wt); db.SaveChanges(); } return(RedirectToAction("Index", "Wordutopia")); } return(View()); }
public ActionResult Create([Bind(Include = "WordID,FWUserID,Word,Pronounciation,Phrase,Hint,Definition,Synonym,IsShareOnline,IsFavourite,IsSkip,Appearance,WAppreance,Score,AdditionInfo")] Wordutopia wordutopia, bool checkResp = false) { //ViewBag.FWUserID = new SelectList(db.Users, "UserID", "Forename", wordutopia.FWUserID); if (ModelState.IsValid) { if (Session["UserID"] != null) { if (checkResp == true) { wordutopia.IsShareOnline = true; } else { wordutopia.IsShareOnline = false; } wordutopia.FWUserID = userid; db.Wordutopias.Add(wordutopia); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(wordutopia)); }
public ActionResult DeleteConfirmed(int id) { Wordutopia wordutopia = db.Wordutopias.Find(id); db.Wordutopias.Remove(wordutopia); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Wordutopia/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wordutopia wordutopia = db.Wordutopias.Find(id); if (wordutopia == null) { return(HttpNotFound()); } return(View(wordutopia)); }
public WordutopiaViewModel(Wordutopia model) : this() { this.WordID = model.WordID; this.FWUserID = model.FWUserID; this.Word = model.Word; this.Pronunciation = model.Pronounciation; this.Phrase = model.Phrase; this.Hint = model.Hint; this.Definition = model.Definition; this.Synonym = model.Synonym; //if (ListOfPreviousWords!=null && !ListOfPreviousWords.Contains(model.WordID)) //{ // ListOfPreviousWords.Add(model.WordID); //} }
public ActionResult Edit([Bind(Include = "WordID,FWUserID,Word,Pronounciation,Phrase,Hint,Definition,Synonym,IsShareOnline,IsFavourite,IsSkip,Appearance,WAppreance,Score,AdditionInfo")] Wordutopia wordutopia, bool chkShare) { if (ModelState.IsValid) { ViewBag.chkShare = chkShare; if (chkShare) { wordutopia.IsShareOnline = true; } else { wordutopia.IsShareOnline = false; } wordutopia.FWUserID = userid; db.Entry(wordutopia).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.FWUserID = new SelectList(db.Users, "UserID", "Forename", wordutopia.FWUserID); return(View(wordutopia)); }
// GET: Wordutopia/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wordutopia wordutopia = db.Wordutopias.Find(id); if (wordutopia.IsShareOnline == true) { ViewBag.chkShare = true; } else { ViewBag.chkShare = false; } if (wordutopia == null) { return(HttpNotFound()); } // ViewBag.FWUserID = new SelectList(db.Users, "UserID", "Forename", wordutopia.FWUserID); return(View(wordutopia)); }
private WordutopiaViewModel InitializeWordutopiaViewModel(Wordutopia model) { return(new WordutopiaViewModel(model)); }
// WTest start tomorrow, send data to answer view wothout timer public ActionResult Answer(int?id) { var r = (from t in db.WTests where t.FWTUserID == userid orderby t.WTestID descending select t).First(); double time = Convert.ToDouble(r.Score); bool minute = r.TestTime ?? false; bool second = r.TimePerWord ?? false; if (minute == true) { if (Session["EndDate"] == null) { Session["EndDate"] = DateTime.Now.AddMinutes(time).ToString("dd-MM-yyyy h:mm:ss tt"); } } else if (second == true) { Session["EndDate"] = DateTime.Now.AddSeconds(time).ToString("dd-MM-yyyy h:mm:ss tt"); } // Session["EndDate"] = DateTime.Now.AddMinutes(minute).ToString("dd-MM-yyyy h:mm:ss tt"); ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; ViewBag.EndDate = Session["EndDate"]; int value = id ?? default(int); if (value == 1) { int wid = fwords[true_count]; WordTest wt = db.WordTests.Where(t => (t.FWordID == wid) && (t.FWtestID == r.WTestID)).FirstOrDefault(); wt.Result = true; db.SaveChanges(); true_count = true_count + 1; } // var d = db.WordTests.Where(t => t.FWtestID==1).FirstOrDefault(); // working //int turnfirst = 0; if (turnfirst == 0) { v = 0; //testid = (from t in db.WTests // orderby t.WTestID descending // select t.WTestID).First(); Wordutopia w = new Wordutopia(); var IDs = db.WordTests.Where(t => t.FWtestID == r.WTestID).ToArray().Select(t => t.FWordID); int index = 0; k = IDs.Count(); // k = total no words foreach (var c in IDs) { w = db.Wordutopias.Find(c); definitions[index] = w.Definition; hint[index] = w.Hint; wordlist[index] = w.Word; fwords[index] = w.WordID; index = index + 1; } turnfirst = 1; } if (v < k) { ViewBag.Definition = definitions[v]; ViewBag.Hint = hint[v]; ViewBag.Word = wordlist[v]; v = v + 1; } else { ViewBag.Status = "complete"; ViewBag.EndDate = null; return(RedirectToAction("Result", new { id = r.WTestID })); } return(View()); }