Пример #1
0
        public ActionResult FinishLearning(string IDList)
        {
            UserDatasController        UDController = new UserDatasController();
            Grammar_PracticeController GPController = new Grammar_PracticeController();
            string userName = User.Identity.GetUserName();
            var    userID   = db.UserData.Where(ud => ud.UserName == userName).
                              Select(ud => ud.ID).First();
            UserData userData = db.UserData.Find(userID);

            if (userData.GrammarList == "")
            {
                userData.GrammarList += IDList;
            }
            else
            {
                userData.GrammarList += "," + IDList;
            }
            UDController.Edit(userData);

            List <string> IDtoList = IDList.Split(',').ToList();

            foreach (var grammarId in IDtoList)
            {
                Grammar_Practice gpData = new Grammar_Practice
                {
                    UserName       = userName,
                    GrammarID      = Int32.Parse(grammarId),
                    LastPracticed  = DateTime.Now.AddDays(1),
                    RepeatInterval = 1
                };

                GPController.Create(gpData);
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Grammar_Practice grammar_Practice = db.Grammar_Practice.Find(id);

            db.Grammar_Practice.Remove(grammar_Practice);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,UserName,GrammarID,LastPracticed,RepeatInterval")] Grammar_Practice grammar_Practice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(grammar_Practice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GrammarID = new SelectList(db.Grammar, "ID", "GrammarUnit", grammar_Practice.GrammarID);
     return(View(grammar_Practice));
 }
Пример #4
0
        // GET: Grammar_Practice/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Grammar_Practice grammar_Practice = db.Grammar_Practice.Find(id);

            if (grammar_Practice == null)
            {
                return(HttpNotFound());
            }
            return(View(grammar_Practice));
        }
Пример #5
0
        // GET: Grammar_Practice/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Grammar_Practice grammar_Practice = db.Grammar_Practice.Find(id);

            if (grammar_Practice == null)
            {
                return(HttpNotFound());
            }
            ViewBag.GrammarID = new SelectList(db.Grammar, "ID", "GrammarUnit", grammar_Practice.GrammarID);
            return(View(grammar_Practice));
        }