protected void btnSubmit_OnClick(object sender, EventArgs e) { var user = Page.User as CustomPrincipal; if (user != null) { var date = DateTime.Now; var submission = new Academic.DbEntities.ActivityAndResource.AssignmentItems.AssignmentSubmissions() { Id = SubmissionId , AssignmentId = AssignmentId , UserClassId = UserClassId }; if (pnlText.Visible) { submission.SubmissionText = CKEditor1.Text; } if (SubmissionId > 0) { submission.ModifiedDate = date; } else { submission.SubmittedDate = date; } #region Files var list = new List <Academic.DbEntities.UserFile>(); if (pnlFileSubmit.Visible) { var files = FilesDisplay1.GetFiles(); if (files != null) { foreach (var f in files) { var fileName = Path.GetFileName(f.FilePath); var fi = new Academic.DbEntities.UserFile() { Id = f.Id, CreatedBy = user.Id , CreatedDate = DateTime.Now , DisplayName = f.FileDisplayName //Path.GetFileName(imageFile.FileName) , FileDirectory = DbHelper.StaticValues.CourseFilesLocation //StaticValue.UserImageDirectory , FileName = fileName //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType) , FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength , FileType = f.FileType //imageFile.ContentType , IconPath = f.IconPath //, //SubjectId = SubjectId , Void = !f.Visible }; list.Add(fi); } } // var files = FilesDisplay1.GetFiles(); // var filelist = new List<Academic.DbEntities.UserFile>(); // //var files = FilesDisplay1.GetFiles(); // if (files != null) // { // var sublist = new // List<Academic.DbEntities.ActivityAndResource.AssignmentItems.AssignmentSubmissionFiles>(); // foreach (var f in files) // { // var subFile = new Academic.DbEntities.ActivityAndResource.AssignmentItems.AssignmentSubmissionFiles() // { // AssignmentSubmissionsId = SubmissionId // ,FileSubmittedDate = date // }; // var fileName = Path.GetFileName(f.FilePath); // var fi = new Academic.DbEntities.UserFile() // { // CreatedBy = user.Id // , // CreatedDate = date // , // DisplayName = f.FileDisplayName //Path.GetFileName(imageFile.FileName) // , // FileDirectory = DbHelper.StaticValues.CourseFilesLocation //StaticValue.UserImageDirectory // , // FileName = fileName // //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType) // , // FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength // , // FileType = f.FileType //imageFile.ContentType // , // IconPath = f.IconPath // , // Id = f.Id // , // //SubjectId = SubjectId // }; // filelist.Add(fi); // } // } } #endregion using (var helper = new DbHelper.Assignments()) { var saved = helper.AddOrUpdateAssignmentSubmission(submission, list); if (saved != null) { Response.Redirect("~/Views/ActivityResource/Assignments/AssignmentView.aspx?SubId=" + SubjectId + "&arId=" + AssignmentId + "&secId=" + SectionId ); } else { lblError.Visible = true; } } } }
protected void btnSave_Click(object sender, EventArgs e) { var user = Page.User as CustomPrincipal; if (user != null) { var file = new Academic.DbEntities.ActivityAndResource.FileResource() { Id = FileResourceId, Name = txtName.Text , Description = CKEditor1.Text , //Display = (byte)ddlDisplay.SelectedIndex //, ShowSize = chkShowSize.Checked , ShowType = chkShowType.Checked , ShowUploadModifiedDate = chkShowUploadModifiedDate.Checked , ShowDescriptionOnCoursePage = chkDisplayDescription.Checked , }; if (ddlDisplay.SelectedIndex == 0) { file.Display = 2; } else { file.Display = 4; } //files var list = new List <Academic.DbEntities.Subjects.SubjectFile>(); var files = FilesDisplay1.GetFiles(); if (files != null) { foreach (var f in files) { var fileName = Path.GetFileName(f.FilePath); var fi = new Academic.DbEntities.Subjects.SubjectFile() { Id = f.Id, CreatedBy = user.Id , CreatedDate = DateTime.Now , DisplayName = f.FileDisplayName //Path.GetFileName(imageFile.FileName) , FileDirectory = DbHelper.StaticValues.CourseFilesLocation //StaticValue.UserImageDirectory , FileName = fileName //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType) , FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength , FileType = f.FileType //imageFile.ContentType , IconPath = f.IconPath , SubjectId = SubjectId , Void = !f.Visible }; list.Add(fi); } } var restriction = RestrictionUC.GetRestriction(); if (!RestrictionUC.IsValid) { return; } using (var helper = new DbHelper.ActAndRes()) { var saved = helper.AddOrUpdateFileResource(file, list, SectionId, restriction); if (saved != null) { Response.Redirect(DbHelper.StaticValues.WebPagePath.CourseDetailPage(SubjectId, SectionId)); //Response.Redirect("~/Views/Course/Section/Master/CourseSectionListing.aspx?SubId=" + SubjectId + "&edit=1#section_" + SectionId); } } } }
//private void PopulateCountry() //{ // List<string> countries = new List<string>(); // var getCultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures); // foreach (var c in getCultureInfo) // { // var getRegionInfo = // new RegionInfo(c.LCID); // var name = getRegionInfo.EnglishName.Split(new char[] { '(' })[0]; // if (!countries.Contains(name)) // { // countries.Add(name); // } // } // countries.Sort(); // var i = 0; // try // { // i = countries.IndexOf("Nepal"); // } // catch // { // } // if (i != 0) // countries.Insert(0, "Select"); // ddlCountry.DataSource = countries; // ddlCountry.DataBind(); // ddlCountry.SelectedIndex = i; //} protected void btnSave_Click(object sender, EventArgs e) { //if (cmbSchoolType.SelectedValue == "" || cmbSchoolType.SelectedValue == "0") //{ // valiSchType.IsValid = false; //} //if (ddlCountry.SelectedIndex == 0) // valiCountry.IsValid = false; if (IsValid) { var user = User as CustomPrincipal; if (user == null) { return; } var school = new Academic.DbEntities.Office.School() { Id = user.SchoolId, Name = txtName.Text, Address = txtAddress.Text, EmailGeneral = txtEmailGeneral.Text, EmailMarketing = "", //txtEmailMarketing.Text, EmailSupport = "", //txtEmailSupport.Text, IsActive = chkActive.Checked, PhoneMain = txtPhoneMain.Text, PhoneAfterHours = "", //txtPhoneAfterHours.Text, Description = CKEditor1.Text, //SchoolTypeId = Convert.ToInt32(cmbSchoolType.Text), Website = txtWeb.Text, CreatedDate = DateTime.Now, ImageId = Convert.ToInt32(hidImageId.Value) }; if (user.SchoolId <= 0) { school.UserId = user.Id; } using (var helper = new DbHelper.Office()) { var files = FilesDisplay1.GetFiles(); var image = new UserFile(); if (files != null) { if (files.Count >= 1) { var f = files[0]; //foreach (var f in files) { var fileName = Path.GetFileName(f.FilePath); image = new Academic.DbEntities.UserFile() { Id = f.Id, CreatedBy = user.Id , CreatedDate = DateTime.Now , DisplayName = f.FileDisplayName //Path.GetFileName(imageFile.FileName) , FileDirectory = DbHelper.StaticValues.SchoolFileLocation //StaticValue.UserImageDirectory , FileName = fileName //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType) , FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength , FileType = f.FileType //imageFile.ContentType , IconPath = f.IconPath , //SubjectId = SubjectId }; if (f.Id > 0) { image.ModifiedBy = user.Id; image.ModifiedDate = DateTime.Now; } } } } var saved = helper.AddOrUpdateSchool(school, image);//FileUpload1.PostedFile //update cookie -- add school Id to the cookie //Page.User.Identity.Name; if (saved != null) { if (user.SchoolId <= 0) { var ok = UpdateSchoolInfoInCookie(user, saved.Id); if (ok) { Response.Redirect("~/ViewsSite/User/Dashboard/Dashboard.aspx"); } else { lblMsg.Text = "Error while saving."; } //---not needed, since redirect is done above //SchoolTypeUC.SavedId = 0; //lblMsg.Visible = true; //lblMsg.Text = "Save Successful."; } else { Response.Redirect("~/About.aspx"); //"//~/Views/Office/"); } } else { lblMsg.Text = "Error while saving."; } } } else { lblMsg.Text = "Some fields are invalid or not filled."; } }