public ActionResult CreateAsDraft(CreateStudyModel csModel) { if (ModelState.IsValid) { try { //Gets the id from JWT. The id is used to retrieve user from database. int id = IdentityHelper.getUserID(User); // Convert to create format CreateStudyHelper cshelper = new CreateStudyHelper(); var curStudy = cshelper.ConvertStudy(csModel, id); var curCriteria = cshelper.ConvertInclusioncriteria(csModel); //Creating as a Draft curStudy.Isdraft = true; IManageStudyHandler manageStudyHandler = new ManageStudyHandler(new bachelordbContext()); manageStudyHandler.CreateStudyDB(curStudy, curCriteria); return(RedirectToAction("Researcher", "Homepage")); } catch (Exception) { cshelper = new CreateStudyHelper(); return(View("Index")); } } return(View("./Index")); }
public ActionResult EditAsDraft(CreateStudyModel csModel) { if (ModelState.IsValid) { try { //Gets the id from JWT. The id is used to retrieve user from database. int id_researcher = IdentityHelper.getUserID(User); // Convert to create the right format CreateStudyHelper cshelper = new CreateStudyHelper(); int id_study = csModel.currentStudy.IdStudy; var curStudy = cshelper.ConvertStudy(csModel, id_researcher, id_study); var curCriteria = cshelper.ConvertInclusioncriteria(csModel); //Storing as a draft curStudy.Isdraft = true; //Storing in the DB IManageStudyHandler msh = new ManageStudyHandler(new bachelordbContext()); msh.EditStudyDB(curStudy, curCriteria); return(RedirectToAction("Researcher", "Homepage")); } catch (Exception) { return(View("Index")); } } EditStudyHelper editStudyHelper = new EditStudyHelper(); return(View("Index", editStudyHelper.CreateEditStudyModel(csModel.currentStudy.IdStudy))); }
public ActionResult Index() { cshelper = new CreateStudyHelper(); return(View(cshelper.DefaultCreateStudyModel())); }