protected void submit_project_button_Click(object sender, EventArgs e) { try { ProjectPromotion projectPromotion = new ProjectPromotion(); if (project_title.Text.Length <= 0) throw new Exception("Please enter project title."); projectPromotion.PROMOTION_TITLE = project_title.Text; if (project_writeup.Text.Length <= 0) throw new Exception("Please write something about the project in Project Write Up."); projectPromotion.PROMOTION_WRITEUP = project_writeup.Text; if (website.Text.Length <= 0) throw new Exception("Please provide a project website."); projectPromotion.PROMOTION_WEBSITE = website.Text; if (Session["zip_file"] == null) throw new Exception("Please upload a zip file."); string zipFile = Session["zip_file"].ToString(); long convertedZipFileId; Int64.TryParse(zipFile, out convertedZipFileId); projectPromotion.PROMOTION_ZIPFILE_ID = convertedZipFileId; if (Session["video_file"] == null) throw new Exception("Please upload a video file."); string videoFile = Session["video_file"].ToString(); long convertedVideoFileId; Int64.TryParse(zipFile, out convertedVideoFileId); projectPromotion.PROMOTION_VIDEOFILE_ID = convertedVideoFileId; long convertedStudentId; if (!Int64.TryParse(Session["userid"].ToString(), out convertedStudentId)) throw new Exception("Cannot find user ID, please contact administrator."); ProjectModule projectModule = new ProjectModule(); projectPromotion = projectModule.promoteProject(convertedStudentId, projectPromotion); Messenger.setMessage(error_message, "Project is submitted successfully!", LEVEL.SUCCESS); } catch (Exception ex) { Messenger.setMessage(error_message, ex.Message, LEVEL.DANGER); } finally { error_modal_control.Show(); refreshUploadedFiles(); } }
/** * Creates a promotional project for student * */ public ProjectPromotion promoteProject(long studentId, ProjectPromotion projectPromotion) { if (session == null || !session.IsOpen) { session = hibernate.getSession(); } Student student = session.CreateCriteria<Student>() .Add(Restrictions.Eq("USER_ID", studentId)) .UniqueResult<Student>(); projectPromotion.PROMOTER_ID = student.USER_ID; session.BeginTransaction(); session.Save(projectPromotion); session.Transaction.Commit(); return projectPromotion; }