public ActionResult EditTestF(EditTestAndQuestionsViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("ViewTests", "Admin")); } _testStore.UpdateTest(model.ToDataModel()); HelpingClass.FEach(model.Questions, x => _questionStore.UpdateQuestion(x)); return(RedirectToAction("ViewTests", "Admin")); }
public ActionResult DeleteConfirm(ModelUser model) { if (!ModelState.IsValid) { return(RedirectToAction("Delete", "Admin")); } List <ModelUserRole> UR = _userRoleStore.GetUserRolesByUser(model.Username).ToList(); HelpingClass.FEach(UR, x => _userRoleStore.DeleteUserRole(x)); _userStore.DeleteUser(model); return(RedirectToAction("Delete", "Admin"));; }
public ActionResult exportStudentAnswers() { List <StudentTestQuestionAnswerModel> model = System.Web.HttpContext.Current.Session["Questions"] as List <StudentTestQuestionAnswerModel>; List <String> lines = new List <string>(); lines.Add(String.Format("Username: {0}; Date: {1}", User.Identity.Name, DateTime.Now)); lines.Add("\n<<<--------------------Questions-------------------->>>"); model.ForEach(cur => lines.Add(cur.ToString())); //Helper.ExportToTextFile(Response, lines); MemoryStream memoryStream = HelpingClass.ExportToTextFile(lines); return(File(memoryStream.GetBuffer(), "text/plain", User.Identity.Name + ".gaadw.txt")); }
public ActionResult exportAllStudentMarks(String ID) { List <ViewStudentMarks> marksies = System.Web.HttpContext.Current.Session["modelViewStudentMarks"] as List <ViewStudentMarks>; if (marksies == null) { marksies = getMarksModel(int.Parse(ID)); } List <String> lines = new List <string>(); lines.Add(String.Format("Username: {0}; Date: {1}\n", User.Identity.Name, DateTime.Now)); lines.Add("Username\tMark\n"); marksies.ForEach(cur => lines.Add(String.Format("{0}\t{1}\n", cur.Name, cur.Presentage).ToString())); MemoryStream memoryStream = HelpingClass.ExportToTextFile(lines); return(File(memoryStream.GetBuffer(), "text/plain", User.Identity.Name + ".txt")); }
public ActionResult Create(PictureViewModel model, HttpPostedFileBase photo) { Thread.Sleep(5000); model.User = User.Identity.Name; model.DatePosted = DateTime.Now; string pictureFolder = Server.MapPath("~/Images"); var path = string.Empty; var fileName = string.Empty; if (photo != null && photo.ContentLength > 0) { fileName = model.User + model.GalleryID.ToString() + Path.GetFileName(photo.FileName); if (!HelpingClass.IsFilePicture(fileName)) { return(Content("The file must be a picture in the format png, jpg or jpeg")); } path = Path.Combine(pictureFolder, fileName); photo.SaveAs(path); } else { return(Content("You must choose a file!")); } model.Path = "~/Images/" + fileName; if (ModelState.IsValid) { var newPicture = ModelMapper.ModelToEntity(model); repo.AddOrUpdate(newPicture); return(Content("Added picture to gallery!")); //return RedirectToAction("ViewGallery", "Gallery", new { id = model.GalleryID }); } return(Content("Something went wrong couldn't add the picture")); }