public IActionResult Index(int?id = 1) { if (id == null || id <= 0) { return(NotFound()); } int numberOfWeek = (int)id; var groupId = _context.Users.First(m => m.UserName == User.Identity.Name).GroupID; var weeks = _context.Lesson.Where(m => m.GroupID == groupId).Include(l => l.Subject) .OrderBy(l => l.Date) .GroupBy(l => l.Date.StartOfWeek(DayOfWeek.Monday)).ToList(); if (numberOfWeek > weeks.Count) { return(View("~/Views/Lessons/DataNotFound.cshtml")); } PaperViewModel paperViewModel = new PaperViewModel { Students = _context.Student.Where(s => s.GroupID == groupId).OrderBy(s => s.LastName).ToList(), Lessons = weeks[numberOfWeek - 1].ToList(), Missings = _context.Missing.ToList() }; ViewBag.id = id; ViewBag.numberOfWeek = numberOfWeek; ViewBag.numWeeks = weeks.Count; return(View(paperViewModel)); }
public ActionResult ModeratePaper(PaperViewModel model, string submit) { switch (submit) { case "Accept": if (ModelState.IsValid) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = "Update Paper set IsActive = 1 where PaperId = @PaperId"; conn.Open(); conn.Execute(query, new { PaperId = model.PaperId }); return(RedirectToAction("ViewModeratorList")); } } break; case "Reject": if (ModelState.IsValid) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = "Update Paper set isRejected = 1 where PaperId = @PaperId"; conn.Open(); conn.Execute(query, new { PaperId = model.PaperId }); return(RedirectToAction("ViewModeratorList")); } } break; } return(View(model)); }
// GET: Papers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Paper paper = db.Papers.Find(id); if (paper == null) { return(HttpNotFound()); } //ViewBag.Id = new SelectList(db.Evaluacions, "Id", "Comentario", paper.Id); var model = new PaperViewModel() { Id = paper.Id, EventoId = paper.Evento.Id, Descripcion = paper.Descripcion, Fecha = paper.Fecha, AreasCientifica = new SelectList(paper.Evento.AreasCientificas.Split(';').AsEnumerable()), Autor = paper.Autor, CoAutores = paper.CoAutores, Nombre = paper.Nombre, }; if (!string.IsNullOrEmpty(paper.Path)) { model.Path = paper.Path.Split('\\').Last(); } return(View(model)); }
public async Task <IActionResult> EditPaper(int id, PaperViewModel model) { if (!ModelState.IsValid) { var paperTypes = await GetAllPaperTypesAsync(); model.PaperTypes = paperTypes; return(View(model)); } var success = await this.materials.EditPaperAsync( id, model.Date, model.PaperTypeId, model.Price, model.SafetyMargin); if (!success) { return(NotFound()); } return(RedirectToAction(nameof(AllPaper))); }
public async Task <ActionResult> Details(Guid id) { var paper = await DB.Papers.FindAsync(id); PaperViewModel model = new PaperViewModel(); model.TeacherName = paper.Teacher.TrueName; model.EditOn = paper.EditOn.ToShortDateString(); model.Id = id; model.TrueOrFalseQuestions = paper.Questions.Where(q => q.Type == QuestionType.判断题).Select(q => new TrueOrFalseQuestionViewModel { Content = q.Content, IsCorrect = (q as TrueOrFalseQuestion).IsCorrect, Type = QuestionType.判断题 }).ToList(); model.SingleQuestions = paper.Questions.Where(q => q.Type == QuestionType.单选题).Select(q => new SingleQuestionViewModel { Content = q.Content, Type = QuestionType.单选题, Options = (q as ChoiceQuestion).Options.OrderBy(o => o.OptionId).Select(o => new OptionViewModel { OptionId = o.OptionId, OptionProperty = o.OptionProperty }).ToList(), CorrectAnswer = (int)((q as ChoiceQuestion).Options.Where(o => o.IsCorrect == true).FirstOrDefault().OptionId), }).ToList(); model.MultipleQuestions = paper.Questions.Where(q => q.Type == QuestionType.多选题).Select(q => new MultipleQuestionViewModel { Content = q.Content, Type = QuestionType.多选题, Options = (q as ChoiceQuestion).Options.OrderBy(o => o.OptionId).Select(o => new MultipleOptionViewModel { OptionId = o.OptionId, OptionProperty = o.OptionProperty, IsCorrect = o.IsCorrect }).ToList(), }).ToList(); return(View(model)); }
public ActionResult Create() { if (TempData["LastPostModel"] == null) { var model = new PaperViewModel(); return(View(model)); } return(View(TempData["LastPostModel"] as PaperViewModel)); }
public async Task <ActionResult> Edit(Guid id, PaperViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Paper oldPaper = await DB.Papers.FindAsync(id); oldPaper.EditOn = DateTime.Now; foreach (var question in oldPaper.Questions) { switch (question.Type) { case QuestionType.判断题: var editedTq = model.TrueOrFalseQuestions.Find(t => t.Id == question.Id); question.Content = editedTq.Content; (question as TrueOrFalseQuestion).IsCorrect = editedTq.IsCorrect; DB.Entry(question).State = EntityState.Modified; break; case QuestionType.单选题: var editedSq = model.SingleQuestions.Find(s => s.Id == question.Id); question.Content = editedSq.Content; foreach (var op in (question as ChoiceQuestion).Options) { op.OptionProperty = editedSq.Options.Find(o => o.OptionId == op.OptionId).OptionProperty; if ((int)op.OptionId == editedSq.CorrectAnswer) { op.IsCorrect = true; } else { op.IsCorrect = false; } } DB.Entry(question).State = EntityState.Modified; break; case QuestionType.多选题: var editedMq = model.MultipleQuestions.Find(m => m.Id == question.Id); question.Content = editedMq.Content; foreach (var op in (question as ChoiceQuestion).Options) { op.OptionProperty = editedMq.Options.Find(o => o.OptionId == op.OptionId).OptionProperty; op.IsCorrect = editedMq.Options.Find(o => o.OptionId == op.OptionId).IsCorrect; } DB.Entry(question).State = EntityState.Modified; break; } } DB.Entry(oldPaper).State = EntityState.Modified; await DB.SaveChangesAsync(); return(RedirectToAction("List")); }
public ActionResult Papers(int listId = 1) { var oturum = _sessionService.GetUyeSession(); var model = new PaperViewModel { Bildirilerim = _bildiriService.GetListByYazarId(oturum.Id, listId), EditorBildirileri = _bildiriService.GetListByEditorId(oturum.Id, listId), HakemBildirileri = _bildiriService.GetListByHakemId(oturum.Id, listId), Oturum = oturum }; TempData["oturum"] = oturum; //_PaperList'te kullanabilmek için oluşturuldu return(View(model)); }
public ActionResult SubmitPaper(PaperViewModel model) { var isCorrectInput = true; if (model.PaperTitle == null) { isCorrectInput = false; ModelState.AddModelError("PaperTitle", "The title is empty."); } if (model.Category == null) { isCorrectInput = false; ModelState.AddModelError("Category", "The category is empty."); } if (model.Author == null) { isCorrectInput = false; ModelState.AddModelError("Author", "The author is empty."); } if (model.Date == null) { isCorrectInput = false; ModelState.AddModelError("Date", "The Date is empty."); } if (model.JournalName == null) { isCorrectInput = false; ModelState.AddModelError("JournalName", "Journal Name is empty."); } if (ModelState.IsValid && isCorrectInput == true) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = string.Format("insert into Paper (PaperTitle, Date, Author, JournalName, Category, Methodology, Practice, IsActive, isAnalyzed, isRejected)" + "values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', 0, 0, 0)", model.PaperTitle, model.Date, model.Author, model.JournalName, model.Category, model.Methodology, model.Practice); conn.Open(); conn.Execute(query); } return(RedirectToAction("Index", "Home")); } return(View(model)); }
public async Task <ActionResult> Edit(Guid id) { Paper paper = await DB.Papers.FirstOrDefaultAsync(p => p.Id == id); if (paper == null) { return(HttpNotFound()); } else { PaperViewModel model = new PaperViewModel(); model.Id = paper.Id; model.MultipleQuestions = paper.Questions.Where(q => q.Type == QuestionType.多选题).Select(q => new MultipleQuestionViewModel { Id = q.Id, Content = q.Content, Type = q.Type, Options = (q as ChoiceQuestion).Options.OrderBy(o => o.OptionId).Select(o => new MultipleOptionViewModel { OptionId = o.OptionId, OptionProperty = o.OptionProperty, IsCorrect = o.IsCorrect }).ToList() }).ToList(); model.SingleQuestions = paper.Questions.Where(q => q.Type == QuestionType.单选题).Select(q => new SingleQuestionViewModel { Id = q.Id, Content = q.Content, Type = q.Type, CorrectAnswer = (int)((q as ChoiceQuestion).Options.Where(o => o.IsCorrect == true).FirstOrDefault().OptionId), Options = (q as ChoiceQuestion).Options.OrderBy(o => o.OptionId).Select(o => new OptionViewModel { OptionId = o.OptionId, OptionProperty = o.OptionProperty }).ToList() }).ToList(); model.TrueOrFalseQuestions = paper.Questions.Where(q => q.Type == QuestionType.判断题).Select(q => new TrueOrFalseQuestionViewModel { Id = q.Id, Content = q.Content, Type = q.Type, IsCorrect = (q as TrueOrFalseQuestion).IsCorrect }).ToList(); return(View(model)); } }
public async Task <IActionResult> AddPaper(PaperViewModel model) { if (!ModelState.IsValid) { var paperTypes = await GetAllPaperTypesAsync(); model.PaperTypes = paperTypes; return(View(model)); } await this.materials.AddPaperAsync( model.Date, model.PaperTypeId, model.Price, model.SafetyMargin); return(RedirectToAction(nameof(AllPaper))); }
public ActionResult Create(PaperViewModel model) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var autor = db.Autores.First(a => a.UsuarioId == userId); var evento = db.Eventos.Find(model.EventoId); var paper = new Paper() { Nombre = model.Nombre, AreaCientifica = model.AreaCientifica, Descripcion = model.Descripcion, Fecha = model.Fecha, Path = model.Path, Autor = autor, Evento = evento, CoAutores = model.CoAutores }; var evaluador = evento.Comite.FirstOrDefault(x => x.AreaCientifica == paper.AreaCientifica); if (evaluador != null) { paper.Evaluador = evaluador; } evento.Papers.Add(paper); autor.Papers.Add(paper); db.Papers.Add(paper); db.SaveChanges(); if (model.Archivo != null) { paper.GuardarArchivo(model.Archivo); //Se modifica la variable path al guardar el archivo. db.Entry(paper).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(int eventoId) { var evento = db.Eventos.FirstOrDefault(x => x.Id == eventoId); if (evento == null) { return(HttpNotFound()); } else if (evento.FechaFinTrabajos.Date < DateTime.Today) { ViewBag.Mensaje = "Ya ha finalizado la fecha de presentacion de trabajos para este evento."; return(View("Error")); } var model = new PaperViewModel() { EventoId = evento.Id, AreasCientifica = new SelectList(evento.AreasCientificas.Split(';').AsEnumerable()), Fecha = DateTime.Today }; return(View(model)); }
public ActionResult Edit(PaperViewModel model) { if (ModelState.IsValid) { Paper paper = db.Papers.Find(model.Id); if (model.Archivo != null) { paper.BorrarArchivo(); paper.GuardarArchivo(model.Archivo); } paper.Nombre = model.Nombre; paper.AreaCientifica = model.AreaCientifica; paper.Fecha = model.Fecha; paper.Path = model.Path; paper.Descripcion = model.Descripcion; paper.CoAutores = model.CoAutores; db.Entry(paper).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Evaluacions, "Id", "Comentario", model.Id); return(View(model)); }
public ActionResult ViewPaper(PaperViewModel model, string submit) { if (ModelState.IsValid) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = "Select PaperTitle = @PaperTitle, Category = @Category, Date = @Date, Author = @Author, JournalName = @JournalName, Publisher = @Publisher, " + "Rating = @Rating, NoOfPeopleRated = @NoOfPeopleRated, Methodology = @Methodology, Practice = @Practice, OutcomeBeingTested = @OutcomeBeingTested," + "ContextWho = @ContextWho, ContextWhat = @ContextWhat, ContextWhere = @ContextWhere, StudyResult = @StudyResult," + "ImplementationIntegrity = @ImplementationIntegrity, ConfidenceRating = @ConfidenceRating, ConfidenceRatingReason = @ConfidenceRatingReason, " + "WhoRated = @WhoRated, ResearchQuestion = @ResearchQuestion, ResearchMethod = @ResearchMethod, ResearchMetrics = @ResearchMetrics," + " ResearchLevel = @ResearchLevel, ParticipantsNature = @ParticipantsNature from Paper;"; conn.Open(); conn.Execute(query, new { PaperTitle = model.PaperTitle, Category = model.Category, Date = model.Date, Author = model.Author, JournalName = model.JournalName, PaperId = model.PaperId, Publisher = model.Publisher, Rating = model.Rating, NoOfPeopleRated = model.NoOfPeopleRated, Methodology = model.Methodology, Practice = model.Practice, OutcomeBeingTested = model.OutcomeBeingTested, ContextWho = model.ContextWho, ContextWhat = model.ContextWhat, ContextWhere = model.ContextWhere, StudyResult = model.StudyResult, ImplementationIntegrity = model.ImplementationIntegrity, ConfidenceRating = model.ConfidenceRating, ConfidenceRatingReason = model.ConfidenceRatingReason, WhoRated = model.WhoRated, ResearchQuestion = model.ResearchQuestion, ResearchMethod = model.ResearchMethod, ResearchMetrics = model.ResearchMetrics, ResearchLevel = model.ResearchLevel, ParticipantsNature = model.ParticipantsNature }); } } return(View(model)); }
public ActionResult PrintMyView(PaperViewModel model) { return(new Rotativa.PartialViewAsPdf("ViewPaper", model)); }
public ActionResult QuickSubmit(PaperViewModel model) { var isCorrectInput = true; if (model.PaperTitle == null) { isCorrectInput = false; ModelState.AddModelError("PaperTitle", "The title is empty."); } if (model.Category == null) { isCorrectInput = false; ModelState.AddModelError("Category", "The category is empty."); } if (model.JournalName == null) { isCorrectInput = false; ModelState.AddModelError("JournalName", "Name of journal is empty."); } if (model.Author == null) { isCorrectInput = false; ModelState.AddModelError("Author", "The author is empty."); } if (model.Date == null) { isCorrectInput = false; ModelState.AddModelError("Date", "The Date is empty."); } if (model.Publisher == null) { isCorrectInput = false; ModelState.AddModelError("Publisher", "Publisher is empty."); } if (model.OutcomeBeingTested == null) { isCorrectInput = false; ModelState.AddModelError("OutcomeBeingTested", "Outcome being tested is empty."); } if (model.ContextWho == null) { isCorrectInput = false; ModelState.AddModelError("ContextWho", "Study context of who is is empty."); } if (model.ContextWhat == null) { isCorrectInput = false; ModelState.AddModelError("ContextWhat", "Study context of what is is empty."); } if (model.ContextWhere == null) { isCorrectInput = false; ModelState.AddModelError("ContextWhere", "Study context of where is is empty."); } if (model.WhoRated == null) { isCorrectInput = false; ModelState.AddModelError("WhoRated", "Who rated is is empty."); } if (model.StudyResult == null) { isCorrectInput = false; ModelState.AddModelError("StudyResult", "Result of study is empty."); } if (model.ImplementationIntegrity == null) { isCorrectInput = false; ModelState.AddModelError("ImplementationIntegrity", "Implementation Integrity cannot be empty."); } if (model.ConfidenceRating == null) { isCorrectInput = false; ModelState.AddModelError("ConfidenceRating", "Confidence Rating cannot be empty"); } if (model.ConfidenceRating == null) { isCorrectInput = false; ModelState.AddModelError("ConfidenceRatingReason", "Reason for Confidence Rating cannot be empty"); } if (model.ResearchQuestion == null) { isCorrectInput = false; ModelState.AddModelError("ResearchQuestion", "Research Question cannot be empty"); } if (model.ResearchMetrics == null) { isCorrectInput = false; ModelState.AddModelError("ResearchMetrics", "Research Metrics cannot be empty"); } if (ModelState.IsValid && isCorrectInput == true) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = string.Format("insert into Paper (PaperTitle, Date, Author, JournalName, Category, Publisher, Methodology, Practice, OutcomeBeingTested, ContextWho," + " ContextWhat, ContextWhere, StudyResult, ImplementationIntegrity, ConfidenceRating, ConfidenceRatingReason, WhoRated, ResearchQuestion, ResearchMethod," + " ResearchMetrics, ResearchLevel, ParticipantsNature, IsActive, isAnalyzed, isRejected) " + "values ('{0}', '{1}','{2}', '{3}','{4}', '{5}','{6}', '{7}', '{8}','{9}', '{10}','{11}', '{12}','{13}', '{14}','{15}', '{16}', '{17}'," + " '{18}', '{19}','{20}', '{21}', 1, 1, 0)", model.PaperTitle, model.Date, model.Author, model.JournalName, model.Category, model.Publisher, model.Methodology, model.Practice, model.OutcomeBeingTested, model.ContextWho, model.ContextWhat, model.ContextWhere, model.StudyResult, model.ImplementationIntegrity, model.ConfidenceRating, model.ConfidenceRatingReason, model.WhoRated, model.ResearchQuestion, model.ResearchMethod, model.ResearchMetrics, model.ResearchLevel, model.ParticipantsNature); conn.Open(); conn.Execute(query); } return(RedirectToAction("Index", "Home")); } return(View(model)); }
public ActionResult AnalyzePaper(PaperViewModel model) { var isCorrectInput = true; if (model.OutcomeBeingTested == null) { isCorrectInput = false; ModelState.AddModelError("OutcomeBeingTested", "Outcome being tested is empty."); } if (model.ContextWho == null) { isCorrectInput = false; ModelState.AddModelError("ContextWho", "Study context of who is is empty."); } if (model.ContextWhat == null) { isCorrectInput = false; ModelState.AddModelError("ContextWhat", "Study context of what is is empty."); } if (model.ContextWhere == null) { isCorrectInput = false; ModelState.AddModelError("ContextWhere", "Study context of where is is empty."); } if (model.StudyResult == null) { isCorrectInput = false; ModelState.AddModelError("StudyResult", "Result of study is empty."); } if (model.ImplementationIntegrity == null) { isCorrectInput = false; ModelState.AddModelError("ImplementationIntegrity", "Implementation Integrity cannot be empty."); } if (model.ConfidenceRating == null) { isCorrectInput = false; ModelState.AddModelError("ConfidenceRating", "Confidence Rating cannot be empty"); } if (model.ConfidenceRating == null) { isCorrectInput = false; ModelState.AddModelError("ConfidenceRatingReason", "Reason for Confidence Rating cannot be empty"); } if (model.ResearchQuestion == null) { isCorrectInput = false; ModelState.AddModelError("ResearchQuestion", "Research Question cannot be empty"); } if (model.ResearchMetrics == null) { isCorrectInput = false; ModelState.AddModelError("ResearchMetrics", "Research Metrics cannot be empty"); } if (ModelState.IsValid && isCorrectInput) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = "Update Paper set OutcomeBeingTested = @OutcomeBeingTested, ContextWho = @ContextWho, ContextWhat = @ContextWhat, ContextWhere = @ContextWhere," + "StudyResult = @StudyResult, ImplementationIntegrity = @ImplementationIntegrity, ConfidenceRating = @ConfidenceRating," + "ConfidenceRatingReason = @ConfidenceRatingReason, WhoRated = @WhoRated, ResearchQuestion = @ResearchQuestion, ResearchMethod = @ResearchMethod," + "ResearchMetrics = @ResearchMetrics, ResearchLevel = @ResearchLevel, ParticipantsNature = @ParticipantsNature, isAnalyzed = 1 where PaperId = @PaperId"; conn.Open(); conn.Execute(query, new { OutcomeBeingTested = model.OutcomeBeingTested, ContextWho = model.ContextWho, ContextWhat = model.ContextWhat, ContextWhere = model.ContextWhere, StudyResult = model.StudyResult, ImplementationIntegrity = model.ImplementationIntegrity, ConfidenceRating = model.ConfidenceRating, ConfidenceRatingReason = model.ConfidenceRatingReason, WhoRated = model.WhoRated, ResearchQuestion = model.ResearchQuestion, ResearchMethod = model.ResearchMethod, ResearchMetrics = model.ResearchMetrics, ResearchLevel = model.ResearchLevel, ParticipantsNature = model.ParticipantsNature, PaperId = model.PaperId }); return(RedirectToAction("ViewAnalystList")); } } return(View(model)); }
public async Task <ActionResult> Create(PaperViewModel paperInfo) { foreach (var item in paperInfo.SingleQuestions) { for (int i = 0; i < 4; i++) { item.Options[i].OptionId = (OptionType)(i + 1); } } foreach (var item in paperInfo.MultipleQuestions) { for (int i = 0; i < item.Options.Count; i++) { item.Options[i].OptionId = (OptionType)(i + 1); } } if (ModelState.IsValid) { var teacher = GetCurrentUser() as Teacher; Paper paper = new Paper(); paper.Exam = new Exam(); paper.EditOn = DateTime.Now; paper.Teacher = teacher; var trueOrFalseQuestionList = new List <TrueOrFalseQuestion>(); foreach (TrueOrFalseQuestionViewModel questioninfo in paperInfo.TrueOrFalseQuestions) { trueOrFalseQuestionList.Add(new TrueOrFalseQuestion { Type = questioninfo.Type, Content = questioninfo.Content, IsCorrect = questioninfo.IsCorrect, }); } ; var singleQuestionList = new List <ChoiceQuestion>(); foreach (SingleQuestionViewModel questioninfo in paperInfo.SingleQuestions) { ChoiceQuestion c = new ChoiceQuestion(); c.Type = questioninfo.Type; c.Content = questioninfo.Content; for (int i = 0; i < 4; i++) { Option o = new Option { OptionProperty = questioninfo.Options[i].OptionProperty, OptionId = questioninfo.Options[i].OptionId }; if ((i + 1) == questioninfo.CorrectAnswer) //view中正确选项是从1开始的,和OptionId的枚举一致,所以这里要加一才能和正确选项相等。 { o.IsCorrect = true; } c.Options.Add(o); } singleQuestionList.Add(c); } var multipleQuestionList = new List <ChoiceQuestion>(); foreach (MultipleQuestionViewModel questioninfo in paperInfo.MultipleQuestions) { ChoiceQuestion c = new ChoiceQuestion(); c.Type = questioninfo.Type; c.Content = questioninfo.Content; for (int i = 0; i < questioninfo.Options.Count; i++) { c.Options.Add(new Option { OptionProperty = questioninfo.Options[i].OptionProperty, IsCorrect = questioninfo.Options[i].IsCorrect, OptionId = questioninfo.Options[i].OptionId }); } multipleQuestionList.Add(c); } paper.Questions.AddRange(trueOrFalseQuestionList); paper.Questions.AddRange(singleQuestionList); paper.Questions.AddRange(multipleQuestionList); DB.Papers.Add(paper); await DB.SaveChangesAsync(); return(RedirectToAction("List")); } ; TempData["LastPostModel"] = paperInfo; return(RedirectToAction("Create")); }
public ActionResult EditPaper(PaperViewModel model, string submit) { switch (submit) { case "Change": var isCorrectInput = true; if (model.PaperTitle == null) { isCorrectInput = false; ModelState.AddModelError("PaperTitle", "The title is empty."); } if (model.Category == null) { isCorrectInput = false; ModelState.AddModelError("Category", "The category is empty."); } if (model.JournalName == null) { isCorrectInput = false; ModelState.AddModelError("JournalName", "Name of journal is empty."); } if (model.Author == null) { isCorrectInput = false; ModelState.AddModelError("Author", "The author is empty."); } if (model.Date == null) { isCorrectInput = false; ModelState.AddModelError("Date", "The Date is empty."); } if (model.Publisher == null) { isCorrectInput = false; ModelState.AddModelError("Publisher", "Publisher is empty."); } if (model.OutcomeBeingTested == null) { isCorrectInput = false; ModelState.AddModelError("OutcomeBeingTested", "Outcome being tested is empty."); } if (model.ContextWho == null) { isCorrectInput = false; ModelState.AddModelError("ContextWho", "Study context of who is is empty."); } if (model.ContextWhat == null) { isCorrectInput = false; ModelState.AddModelError("ContextWhat", "Study context of what is is empty."); } if (model.ContextWhere == null) { isCorrectInput = false; ModelState.AddModelError("ContextWhere", "Study context of where is is empty."); } if (model.StudyResult == null) { isCorrectInput = false; ModelState.AddModelError("StudyResult", "Result of study is empty."); } if (model.ImplementationIntegrity == null) { isCorrectInput = false; ModelState.AddModelError("ImplementationIntegrity", "Implementation Integrity cannot be empty."); } if (model.ConfidenceRating == null) { isCorrectInput = false; ModelState.AddModelError("ConfidenceRating", "Confidence Rating cannot be empty"); } if (model.ConfidenceRatingReason == null) { isCorrectInput = false; ModelState.AddModelError("ConfidenceRatingReason", "Reason for Confidence Rating cannot be empty"); } if (model.WhoRated == null) { isCorrectInput = false; ModelState.AddModelError("WhoRated", "Who Rated cannot be empty"); } if (model.ResearchQuestion == null) { isCorrectInput = false; ModelState.AddModelError("ResearchQuestion", "Research Question cannot be empty"); } if (model.ResearchMetrics == null) { isCorrectInput = false; ModelState.AddModelError("ResearchMetrics", "Research Metrics cannot be empty"); } if (ModelState.IsValid && isCorrectInput) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = "Update Paper set PaperTitle = @PaperTitle, Category = @Category, Date = @Date, Author = @Author, JournalName = @JournalName, Publisher = @Publisher," + "Rating = @Rating, NoOfPeopleRated = @NoOfPeopleRated, Methodology = @Methodology,Practice = @Practice, OutcomeBeingTested = @OutcomeBeingTested," + "ContextWho = @ContextWho,ContextWhat = @ContextWhat, ContextWhere = @ContextWhere,StudyResult = @StudyResult," + "ImplementationIntegrity = @ImplementationIntegrity, ConfidenceRating = @ConfidenceRating," + "ConfidenceRatingReason = @ConfidenceRatingReason, WhoRated = @WhoRated, ResearchQuestion = @ResearchQuestion, ResearchMethod = @ResearchMethod," + "ResearchMetrics = @ResearchMetrics, ResearchLevel = @ResearchLevel, ParticipantsNature = @ParticipantsNature where PaperId = @PaperId"; conn.Open(); conn.Execute(query, new { PaperTitle = model.PaperTitle, Category = model.Category, Date = model.Date, Author = model.Author, JournalName = model.JournalName, PaperId = model.PaperId, Publisher = model.Publisher, Rating = model.Rating, NoOfPeopleRated = model.NoOfPeopleRated, Methodology = model.Methodology, Practice = model.Practice, OutcomeBeingTested = model.OutcomeBeingTested, ContextWho = model.ContextWho, ContextWhat = model.ContextWhat, ContextWhere = model.ContextWhere, StudyResult = model.StudyResult, ImplementationIntegrity = model.ImplementationIntegrity, ConfidenceRating = model.ConfidenceRating, ConfidenceRatingReason = model.ConfidenceRatingReason, WhoRated = model.WhoRated, ResearchQuestion = model.ResearchQuestion, ResearchMethod = model.ResearchMethod, ResearchMetrics = model.ResearchMetrics, ResearchLevel = model.ResearchLevel, ParticipantsNature = model.ParticipantsNature }); return(RedirectToAction("AdministratePaper")); } } break; case "Reject": if (ModelState.IsValid) { using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Serler"].ConnectionString)) { var query = "Update Paper set isRejected = 1 where PaperId = @PaperId"; conn.Open(); conn.Execute(query, new { PaperId = model.PaperId }); return(RedirectToAction("AdministratePaper")); } } break; } return(View(model)); }