示例#1
0
 public GameAnswer(Answer answer)
 {
     Usable = true; ;
     AnswerString = answer.AnswerString;
     using (Repos repo = new Repos())
     {
         answer.Pictures = repo.GetPicturesByAnswerID(answer.AnswerID).ToList();
     }
     Pictures = ConvertPictures(answer.Pictures);
 }
示例#2
0
 public ActionResult AdminDeleteConfirmed(int id)
 {
     using (Repos repo = new Repos())
     {
         if (!repo.DeleteModule(id))
         {
             //ERROR DELETING MODULE
         }
     }
     return RedirectToAction("Index", new { controller = "Profile" });
 }
示例#3
0
 public GameModule(Module module)
 {
     ModuleID = module.ModuleID;
     Name = module.Name;
     DefaultNumAnswers = module.DefaultNumAnswers;
     DefaultNumQuestions = module.DefaultNumQuestions;
     DefaultTime = module.DefaultTime;
     using (Repos repo = new Repos())
     {
         module.Answers = repo.GetAnswerList(module.ModuleID).ToList();
     }
     Answers = ConvertAnswers(module.Answers);
     rightAnswerString = module.rightAnswerString;
     wrongAnswerString = module.wrongAnswerString;
 }
示例#4
0
 public GameModule(Module module)
 {
     ModuleID            = module.ModuleID;
     Name                = module.Name;
     DefaultNumAnswers   = module.DefaultNumAnswers;
     DefaultNumQuestions = module.DefaultNumQuestions;
     DefaultTime         = module.DefaultTime;
     using (Repos repo = new Repos())
     {
         module.Answers = repo.GetAnswerList(module.ModuleID).ToList();
     }
     Answers           = ConvertAnswers(module.Answers);
     rightAnswerString = module.rightAnswerString;
     wrongAnswerString = module.wrongAnswerString;
 }
示例#5
0
 public ActionResult Create([Bind(Include = "AnswerID,AnswerString,ModuleID,PictureCount")] Answer answer)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (Repos repo = new Repos())
             {
                 repo.AddAnswer(answer);
             }
             return RedirectToAction("Create", new { id = answer.ModuleID });
         }
     }
     catch (Exception) { }
     return RedirectToAction("Create", new { error = "You cannot add duplicate answers" });
 }
示例#6
0
 public ActionResult Delete(int? id)
 {
     int ID = id ?? 0;
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Category category;
     using (Repos repo = new Repos())
     {
         category = repo.GetCategoryByID(ID);
     }
     if (category == null)
     {
         return HttpNotFound();
     }
     return View(category);
 }
示例#7
0
 public ActionResult Delete(int? id)
 {
     int ID = id ?? 0;
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Answer answer;
     using (Repos repo = new Repos())
     {
         answer = repo.GetAnswerByID(ID);
     }
     if (answer == null)
     {
         return HttpNotFound();
     }
     return View(answer);
 }
示例#8
0
 public ActionResult Create(int ID, string error)
 {
     Module module;
     try
     {
         using (Repos repo = new Repos())
         {
             module = repo.GetModuleByID(ID);
             ViewBag.ModuleID = module.ModuleID;
             ViewBag.ModuleName = module.Name;
             ViewBag.ModuleAnsList = repo.GetAnswerList(module.ModuleID);
         }
     }
     catch (Exception)
     {
         ViewBag.Error = error;
     }
     return View();
 }
示例#9
0
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName")] Category category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (Repos repo = new Repos())
                    {
                        repo.AddCategory(category);
                    }
                    return RedirectToAction("Index");
                }
                return View(category);
            }
            catch (Exception) { }

            //TODO - error when adding new category
            //return RedirectToAction("Create", new { error = "You cannot add duplicate answers" });
            return RedirectToAction("Create");
        }
示例#10
0
 public ActionResult AdminDelete(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     int ID = id ?? 0;
     Module module;
     using (Repos repo = new Repos())
     {
         module = repo.GetModuleByID(ID);
         module.Answers = repo.GetAnswerList(ID).ToList();
         foreach (Answer answer in module.Answers)
         {
             answer.Pictures = repo.GetPicturesByAnswerID(answer.AnswerID).ToList();
         }
     }
     if (module == null)
     {
         return HttpNotFound();
     }
     return View(module);
 }
示例#11
0
 public ActionResult Edit([Bind(Include = "ModuleID,Name,CategoryId,Description,DefaultNumAnswers,DefaultTime,DefaultNumQuestions,isPrivate")] Module module)
 {
     if (ModelState.IsValid)
     {
         using (Repos repo = new Repos())
         {
             if (!repo.UpdateModule(module))
             {
                 //ERROR SAVING TO DATABASE
             }
         }
         return RedirectToAction("Index", new { controller = "Profile" });
     }
     PopulateCategoryDropDownList(module.CategoryId);
     return View(module);
 }
示例#12
0
        public ActionResult Index()
        {
            IEnumerable<Category> cats;
            using (Repos repo = new Repos())
            {
                cats = repo.GetCategoryList();
            }

            return View(cats);
        }
示例#13
0
 public ActionResult Edit([Bind(Include = "CategoryID,CategoryName")] Category category)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (Repos repo = new Repos())
             {
                 repo.AddCategory(category);
             }
             return View(category);
         }
     }
     catch (Exception) { }
     return RedirectToAction("Index");
 }
示例#14
0
 public ActionResult Create([Bind(Include = "ModuleID,Name,CategoryId,Description,DefaultNumAnswers,DefaultTime,DefaultNumQuestions,isPrivate")] Module module)
 {
     if (ModelState.IsValid)
     {
         //**********NOTE****************//
         //Make sure that a user is logged in to access this page
         if (((User.IsInRole("Learner")) || (User.IsInRole("Admin"))))
         {
             var userID = User.Identity.GetUserId();
             ApplicationUser currentUser = db.Users.Single(x => x.Id == userID);
             module.User = currentUser;
         }
         using (Repos repo = new Repos())
         {
             if (!repo.AddModule(module))
             {
                 //ERROR SAVING TO DATABASE
             }
         }
         PopulateCategoryDropDownList(module.CategoryId);
         return RedirectToAction("Index", "Profile");
     }
     return View(module);
 }
示例#15
0
 public ActionResult EditPictureView(int? id)
 {
     int ID = id ?? 0;
     Picture picture;
     using (Repos repo = new Repos())
     {
         picture = repo.GetPictureByID(ID);
     }
     return View(picture);
 }
示例#16
0
        public ActionResult Edit([Bind(Include = "AnswerID,AnswerString,ModuleID,PictureCount")] Answer answer, int? ModuleID)
        {
            if (ModelState.IsValid)
            {
                using (Repos repo = new Repos())
                {
                    repo.UpdateAnswer(answer);
                    ViewBag.Pictures = repo.GetViewBagPictureList(answer.AnswerID);
                }

                return RedirectToAction("Create", new { controller = "Answers", id = answer.ModuleID });
            }
            ViewBag.ModuleID = new SelectList(db.Modules, "ModuleID", "Name");
            return View(answer);
        }
示例#17
0
 public ActionResult DeleteConfirmed(int id)
 {
     Category category;
     using (Repos repo = new Repos())
     {
         category = repo.GetCategoryByID(id);
         repo.DeleteCategory(category.CategoryID);
     }
     return RedirectToAction("Index");
 }
示例#18
0
        public ActionResult DisableModule([Bind(Include = "Name, isDisabled, DisableModuleNote, DisableReason")] DisableModuleViewModel userModule)
        {
            if (ModelState.IsValid)
            {
                Module module;
                using (Repos repo = new Repos())
                {
                    module = repo.GetModuleByID(userModule.ModuleID);
                    module.Answers = repo.GetAnswerList(userModule.ModuleID).ToList();
                    foreach (Answer answer in module.Answers)
                    {
                        answer.Pictures = repo.GetPicturesByAnswerID(answer.AnswerID).ToList();
                    }
                }

                module.isDisabled = userModule.isDisabled;
                module.DisableModuleNote = userModule.DisableModuleNote;
                module.DisableReason = userModule.DisableReason;

                using (Repos repo = new Repos())
                {
                    if (!repo.UpdateModule(module))
                    {
                        //ERROR SAVING TO DATABASE
                    }
                }
                return RedirectToAction("Index", new { controller = "ModulesEdit" });
            }
            return View(userModule);
        }
示例#19
0
 public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     int ID = id ?? 0;
     Picture picture;
     using (Repos repo = new Repos())
     {
         picture = repo.GetPictureByID(ID);
     }
     if (picture == null)
     {
         return HttpNotFound();
     }
     ViewBag.AnswerID = new SelectList(db.Answers, "AnswerID", "AnswerString", picture.AnswerID);
     return View(picture);
 }
示例#20
0
 public ActionResult Create(int? id)
 {
     ViewBag.AnswerID = id;
     Picture picture = new Picture();
     int ID = id ?? 0;
     using (Repos repo = new Repos())
     {
         picture.Answer = repo.GetAnswerByID(ID);
     }
     return View(picture);
 }
示例#21
0
 public ActionResult Index()
 {
     //ConvertAllPicturesToStringData();
     IEnumerable<Picture> pictures;
     using (Repos repo = new Repos())
     {
         pictures = repo.GetAllPictures();
     }
     return View(pictures);
 }
示例#22
0
 public ActionResult ImageEditor(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     int ID = id ?? 0;
     Picture picture;
     using (Repos repo = new Repos())
     {
         picture = repo.GetPictureByID(ID);
     }
     if (picture == null)
     {
         return HttpNotFound();
     }
     return View(picture);
 }
示例#23
0
        public ActionResult Edit(int? id)
        {
            int ID = id ?? 0;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
            Response.AppendHeader("Expires", "-1"); // Proxies.
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Answer answer;
            using (Repos repo = new Repos())
            {
                answer = repo.GetAnswerByID(ID);
                ViewBag.Pictures = repo.GetViewBagPictureList(answer.AnswerID);
            }
            if (answer == null)
            {
                return HttpNotFound();
            }

            ViewBag.ModuleID = new SelectList(db.Modules, "ModuleID", "Name");
            return View(answer);
        }
示例#24
0
 public ActionResult DeleteConfirmed(int id)
 {
     int answerID;
     using (Repos repo = new Repos())
     {
         answerID = repo.GetPictureByID(id).AnswerID;
         repo.DeletePicture(id);
     }
     return RedirectToAction("edit", new { controller = "Answers", id = answerID });
 }
示例#25
0
 // GET: /Answers/
 public ActionResult Index(int id = 0)
 {
     IEnumerable<Answer> answers;
     using (Repos repos = new Repos())
     {
         answers = repos.GetAnswerList(id);
     }
     return View(answers);
 }
示例#26
0
        public ActionResult Create([Bind(Include = "Attribution,PictureID")] Picture picture, int? id)
        {
            int ID = id ?? 0;
            pictureToSave = new Picture();
            pictureToSave.AnswerID = ID;
            pictureToSave.Location = "NotYetConstructed";
            if (picture.Attribution == null)
                pictureToSave.Attribution = "";
            else
                pictureToSave.Attribution = picture.Attribution;

            ConvertImageToDataString(pictureToSave, Request.Files[0].InputStream);
            ViewBag.AnswerID = ID;

            if (ModelState.IsValid)
            {
                using (Repos repo = new Repos())
                {
                    if (!repo.AddPicture(pictureToSave))
                    {
                        //ERROR SAVING TO DATABASE
                    }
                }
                return RedirectToAction("edit", new { controller = "Answers", id = pictureToSave.AnswerID });
            }
            ViewBag.AnswerID = new SelectList(db.Answers, "AnswerID", "AnswerString", pictureToSave.AnswerID);
            return View(pictureToSave);
        }
示例#27
0
        public ActionResult Index(string sortOrder, string searchString, string userSearchString)
        {
            ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "name_asc" : "";
            IEnumerable<Module> modules;
            using (Repos repo = new Repos())
            {
                modules = repo.GetModuleList();
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                modules = modules.Where(m => m.Name.Contains(searchString));
            }

            if (!String.IsNullOrEmpty(userSearchString))
            {
                modules = modules.Where(m => m.User.UserName.Contains(searchString));
            }

            switch (sortOrder)
            {
                case "name_asc":
                    modules = modules.OrderBy(m => m.Name);
                    break;
            }
            return View(modules);
        }
示例#28
0
 public ActionResult Edit([Bind(Include = "PictureID,AnswerID,Attribution,PictureData")] Picture picture)
 {
     if (ModelState.IsValid)
     {
         using (Repos repo = new Repos())
         {
             if (!repo.UpdatePicture(picture))
             {
                 //ERROR UPDATING DATABASE
             }
         }
         return RedirectToAction("edit", new { controller = "Answers", id = picture.AnswerID });
     }
     ViewBag.AnswerID = new SelectList(db.Answers, "AnswerID", "AnswerString", picture.AnswerID);
     return View(picture);
 }
示例#29
0
 public ActionResult DeleteConfirmed(int id)
 {
     Answer answer;
     using (Repos repo = new Repos())
     {
         answer = repo.GetAnswerByID(id);
         repo.DeleteAnswer(answer.AnswerID);
     }
     return RedirectToAction("Create", new { id = answer.ModuleID });
 }
示例#30
0
 private void PopulateCategoryDropDownList(object selectedCategory = null)
 {
     IEnumerable<Category> categoryQuery;
     using (Repos repo = new Repos())
     {
         categoryQuery = repo.GetCategoryList();
     }
     ViewBag.CategoryId = new SelectList(categoryQuery.Distinct().ToList(), "CategoryId", "CategoryName", selectedCategory);
 }