public ActionResult Account(HomeModel model) { if (Request.IsAuthenticated) { ViewBag.Message = "The Answer App"; ViewBag.Username = User.Identity.Name; AnswerApp.Models.AnswerAppDataContext db = new AnswerApp.Models.AnswerAppDataContext(); AnswerApp.Models.User thisUser = db.Users.Single(d => d.UserName.Equals(User.Identity.Name)); //thisUser.MetaData = ""; db.SubmitChanges(); if (thisUser == null) { return RedirectToAction("LogIn", "Account"); }//This should never happen AnswerApp.Models.SelectModel fakeModel = new AnswerApp.Models.SelectModel(); fakeModel.Textbook = "All"; fakeModel.Unit = "All"; fakeModel.Chapter = "All"; fakeModel.Section = "All"; fakeModel.Page = "All"; fakeModel.Question = "All"; ViewData["SelectionList"] = GenerateSelectionList(fakeModel, 1); //TESTING AND OR DEBUGGING PURPOSES ONLY if (User.Identity.Name.Equals("administrator")) { //AnswerAppDataContext db = new AnswerAppDataContext(); List<User> UserList = new List<User>(); UserList = db.Users.ToList<User>(); foreach (User theUser in UserList) { ViewData["UserList"] += "[" + theUser.Unique_Id + "," + theUser.UserName + "," + theUser.Email + "," + theUser.Password + "," + theUser.PasswordQuestion + "," + theUser.PasswordAnswer + "," + theUser.Answers + "," + theUser.MetaData + "]"; } } //TESTING AND OR DEBUGGING PURPOSES ONLY*/ ViewData["Test"] = Collapsable("Test1", "Testtext"); ViewData["Test"] += Collapsable("Test2", "Testtext"); ViewData["Test"] += Collapsable("Test3", Collapsable("Test4", "Testtext")); ViewData["AllContent"] = AllContent; ViewData["AllHeader"] = AllHeader; ViewData["Credit"] = thisUser.Credit; return View(model); } else { return RedirectToAction("LogIn", "Account"); //return View(); } }
public void Index() { // Arrange HomeController controller = new HomeController(); // Act HomeModel model = new HomeModel(); ViewResult result = controller.Index(model) as ViewResult; // Assert Assert.AreEqual("Welcome to ASP.NET MVC!", result.ViewBag.Message); }
public ActionResult DisplayUsers(HomeModel model) { if (User.Identity.Name.Equals("administrator")) { AnswerAppDataContext db = new AnswerAppDataContext(); List<User> UserList = new List<User>(); UserList = db.Users.ToList<User>(); foreach (User theUser in UserList) { ViewData["UserList"] += theUser.UserName; } } return View(model); }
public ActionResult Index(HomeModel model) { if (Request.IsAuthenticated) { ViewBag.Message = "The Answer App"; //String Username = User.Identity.Name; ViewBag.Username = User.Identity.Name;//Username; AnswerApp.Models.AnswerAppDataContext db = new AnswerApp.Models.AnswerAppDataContext(); AnswerApp.Models.User thisUser = db.Users.Single(d => d.UserName.Equals(User.Identity.Name)); if (thisUser == null) { RedirectToAction("LogOn", "Account"); }//This should never happen else { //Calculate the percentages of each textbook the user has purchased /*List<String> UserTextbooks = new List<String>(); ; List<String> UserAnswers = thisUser.Answers.Split(new char[1] { ';' }).ToList(); foreach (String theAnswer in UserAnswers) { String[] AnswerProperties = theAnswer.Split(new char[1] { '_' });//AnswerProperties[0] is theTextbook if (!UserTextbooks.Contains(AnswerProperties[0])) { UserTextbooks.Add(AnswerProperties[0]);//If it is not already in the list of textbooks add it String[] AnswerPercentage = theAnswer.Split(new char[1] { ',' }); Textbook thisTextbook = new Textbook(); thisTextbook.TextbookTitle = AnswerProperties[0]; thisTextbook.TextbookPercentage = AnswerPercentage[1]; model.UserTextbooks.Add(thisTextbook); } }//*/ } return View(model); } else { return RedirectToAction("LogOn", "Account"); //return View(); } }
public ActionResult ResourceUnavailable(HomeModel model) { return View(); }
public ActionResult Index(HomeModel model, String returnUrl) { //Extract the known catagory values from the user's meta data AnswerApp.Models.AnswerAppDataContext db = new AnswerAppDataContext(); AnswerApp.Models.User thisUser = db.Users.Single(d => d.UserName.Equals(User.Identity.Name)); String knownCategoryValues = thisUser.MetaData; //Convert to proper format knownCategoryValues = knownCategoryValues.Replace("Textbook:", ""); knownCategoryValues = knownCategoryValues.Replace("Unit:", ""); knownCategoryValues = knownCategoryValues.Replace("Chapter:", ""); knownCategoryValues = knownCategoryValues.Replace("Section:", ""); knownCategoryValues = knownCategoryValues.Replace("Page:", ""); knownCategoryValues = knownCategoryValues.Replace("Question:", ""); //Disect the file name for it's file properties String[] properties = knownCategoryValues.Split(new char[1] { ';' }); String Textbook_Title = null; String Unit_Title = null; String Chapter_Title = null; String Section_Title = null; String Page_Number = null; String Question_Number = null; if (properties.Length > 0) { Textbook_Title = properties[0]; } if (properties.Length > 1) { Unit_Title = properties[1]; } if (properties.Length > 2) { Chapter_Title = properties[2]; } if (properties.Length > 3) { Section_Title = properties[3]; } if (properties.Length > 4) { Page_Number = properties[4]; } if (properties.Length > 5) { Question_Number = properties[5]; }//.Split(new char[1] { '.' })[0];//Truncate ".pdf" from the end of the file name //Populate parent groupings based on childgroupings if (!Question_Number.Equals("All") && Page_Number.Equals("All")) { Page_Number = db.Questions.Single<Question>(q => q.Question_Number.Equals(Question_Number)).Page_Number; } if (!Page_Number.Equals("All") && Section_Title.Equals("All")) { Section_Title = db.Pages.Single<Page>(p => p.Page_Number.Equals(Page_Number)).Section_Title; } if (!Section_Title.Equals("All") && Chapter_Title.Equals("All")) { Chapter_Title = db.Sections.Single<Section>(s => s.Section_Title.Equals(Section_Title)).Chapter_Title; } if (!Chapter_Title.Equals("All") && Unit_Title.Equals("All")) { Unit_Title = db.Chapters.Single<Chapter>(c => c.Chapter_Title.Equals(Chapter_Title)).Unit_Title; } if (Textbook_Title.Equals("Select a Textbook")) { return View(); } AnswerApp.Models.SelectModel theSelectModel = new SelectModel(); theSelectModel.Textbook = Textbook_Title; theSelectModel.Unit = Unit_Title; theSelectModel.Chapter = Chapter_Title; theSelectModel.Section = Section_Title; theSelectModel.Page = Page_Number; theSelectModel.Question = Question_Number; return RedirectToAction("ViewAnswer/" + User.Identity.Name, "Answers", theSelectModel); }
public ActionResult Index(HomeModel model) { if (Request.IsAuthenticated) { ViewBag.Message = "The Answer App"; ViewBag.Username = User.Identity.Name; AnswerApp.Models.AnswerAppDataContext db = new AnswerApp.Models.AnswerAppDataContext(); AnswerApp.Models.User thisUser = db.Users.Single(d => d.UserName.Equals(User.Identity.Name)); if (thisUser == null) { return RedirectToAction("LogOn", "Account"); }//This should never happen AnswerApp.Models.SelectModel fakeModel = new AnswerApp.Models.SelectModel(); fakeModel.Textbook = "All"; fakeModel.Unit = "All"; fakeModel.Chapter = "All"; fakeModel.Section = "All"; fakeModel.Page = "All"; fakeModel.Question = "All"; ViewData["SelectionList"] = GenerateSelectionList(fakeModel); return View(model); } else { return RedirectToAction("LogOn", "Account"); //return View(); } }
public ActionResult Pricing(HomeModel model) { //AnswerAppDataContext db = new AnswerAppDataContext(); //User administrator = db.Users.Single<User>(a => a.UserName.Equals("administrator")); //administrator.Answers = ""; //Int32 credit = 3; //administrator.Credit = 3;// credit;// 3;// Convert.ToInt32(credit);// credit; //db.SubmitChanges(); /*SelectModel container = new SelectModel(); SelectModel containee = new SelectModel(); container.Textbook = "Mathematics 10"; containee.Textbook = "Mathematics 10"; container.Unit = "Unit 1 Measurement"; containee.Unit = "Unit 1 Measurement"; container.Chapter = "Chapter 3 Right Triangle Trigonometry"; containee.Chapter = "Chapter 3 Right Triangle Trigonometry"; container.Section = "3.2 The Sine and Cosine Ratios"; containee.Section = "3.2 The Sine and Cosine Ratios"; container.Page = "121"; containee.Page = "121"; container.Question = "8"; containee.Question = "8"; if (container.Contains("Mathematics 10_Unit 1 Measurement_Chapter 3 Right Triangle Trigonometry_3.2 The Sine and Cosine Ratios_121_8")) { return RedirectToAction("Index", "Home"); }*/ return View(model); }
public ActionResult ResourceUnavailable(HomeModel model) { AnswerApp.Models.AnswerAppDataContext db = new AnswerApp.Models.AnswerAppDataContext(); AnswerApp.Models.User administrator = db.Users.Single<User>(u => u.UserName.Equals("administrator")); //administrator.Answers = ""; db.SubmitChanges(); return View(); }
public ActionResult Index(HomeModel model) { if (Request.IsAuthenticated) { ViewBag.Message = "The Answer App"; ViewBag.Username = User.Identity.Name; AnswerApp.Models.AnswerAppDataContext db = new AnswerApp.Models.AnswerAppDataContext(); AnswerApp.Models.User thisUser = db.Users.Single(d => d.UserName.Equals(User.Identity.Name)); thisUser.MetaData = ""; if (thisUser == null) { return RedirectToAction("LogOn", "Account"); }//This should never happen AnswerApp.Models.SelectModel fakeModel = new AnswerApp.Models.SelectModel(); fakeModel.Textbook = "All"; fakeModel.Unit = "All"; fakeModel.Chapter = "All"; fakeModel.Section = "All"; fakeModel.Page = "All"; fakeModel.Question = "All"; ViewData["SelectionList"] = GenerateSelectionList(fakeModel); //TESTING AND OR DEBUGGING PURPOSES ONLY if (User.Identity.Name.Equals("administrator")) { //AnswerAppDataContext db = new AnswerAppDataContext(); List<User> UserList = new List<User>(); UserList = db.Users.ToList<User>(); foreach (User theUser in UserList) { ViewData["UserList"] += "[" + theUser.UserName + "," + theUser.Password + "," + theUser.MetaData + "," + theUser.Answers + "]"; } List<Transaction> TransactionList = new List<Transaction>(); TransactionList = db.Transactions.ToList<Transaction>(); foreach (Transaction theTransaction in TransactionList) { ViewData["UserList"] += db.Users.Single<User>(u => u.UserName.Equals("administrator")).MetaData + "[" + theTransaction.Transaction_ID + "]"; ViewData["TransactionList"] += "[" + theTransaction.Transaction_ID + "]"; } } //TESTING AND OR DEBUGGING PURPOSES ONLY*/ return View(model); } else { return RedirectToAction("LogOn", "Account"); //return View(); } }