// GET: api/Teacher/5 public AssignmentUpload Get(int AssignmentNO) { try { AssignmentUpload p = new AssignmentUpload(); p = p.gets(AssignmentNO); return(p); }catch (Exception ex) { return(null); } }
public IHttpActionResult Login(AssignmentUpload c) { try { bool b = c.TeacherLogin(c); return(Ok(true)); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public IHttpActionResult GetStudentList(int Lesson) { AssignmentUpload up = new AssignmentUpload(); try { List <AssignmentUpload> stlist = up.getListOfstudents(Lesson); return(Ok(stlist)); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public string PostAssignment(AssignmentUpload p) { AssignmentUpload up = new AssignmentUpload(); try { p.AssignmentFile = System.Convert.FromBase64String(p.ss); string s = up.insert(p); return(s); }catch (Exception ex) { return(ex.ToString()); } }
protected void uploadAssignment_Click(object sender, EventArgs e) { string filename = ""; if (AssignmentUpload.FileName != "") { filename = AssignmentUpload.FileName; AssignmentUpload.SaveAs(Server.MapPath("~/LMS/Assignment/" + filename)); } else { return; } Assignments_tbl asgmt = new Assignments_tbl { CourseID = int.Parse(Request.QueryString["course"]), Assignment_Path = filename, DueDate = DueDate.SelectedDate, marks = int.Parse(Markstxt.Text), Status = 0, Assignment_Title = AssignmentTitle.Text }; DBFunctions db = new DBFunctions(); db.addassignment(asgmt); Response.Redirect("UploadAssignments.aspx?course=" + Request.QueryString["course"] + "&tab=assignments"); }
public ActionResult SubmitAssignment(AssignmentUpload assignmentUpload) { int userId = int.Parse(Session["UserId"].ToString()); using (EastWoodEntities db = new EastWoodEntities()) { // Get all files from Request object HttpFileCollectionBase files = Request.Files; // validate file size if (Request.Files.Count > 0) { HttpPostedFileBase file = files[0]; var assignment = db.Assignments.Where(w => w.AssignmentId == assignmentUpload.AssignmentId).FirstOrDefault(); if (assignment == null || file.ContentLength > assignment.AssignmentMaxFileSize) { ViewBag.Message = "File size is exceede the allowed maximum upload size : " + FileHelper.GetConvertedFileSize(assignment.AssignmentMaxFileSize); return(Redirect("/Student/ViewAssignment/" + assignmentUpload.AssignmentId + "?Message=" + "File size is exceede the allowed maximum upload size : " + FileHelper.GetConvertedFileSize(assignment.AssignmentMaxFileSize))); } } int studentId = db.Students.Where(w => w.UserId == userId).Select(s => s.StudentId).FirstOrDefault(); if (studentId == 0) { return(Redirect("/")); } List <Attachment> attachments = new List <Attachment>(); AssignmentUpload newUpload; // create Item if (assignmentUpload.AssignmentUploadId != 0) { newUpload = db.AssignmentUploads.Where(w => w.AssignmentUploadId == assignmentUpload.AssignmentUploadId).FirstOrDefault(); } else { newUpload = new AssignmentUpload(); } newUpload.AssignmentUploadSubmittedOn = DateTime.Now; newUpload.AssignmentUploadIsAfterDeadline = assignmentUpload.AssignmentUploadIsAfterDeadline; newUpload.AssignmentUploadGrade = Grades.NOT_MARKED; newUpload.AssignmentUploadMarks = 0; newUpload.StudentId = studentId; newUpload.AssignmentId = assignmentUpload.AssignmentId; if (assignmentUpload.AssignmentUploadId == 0) { db.AssignmentUploads.Add(newUpload); } db.SaveChanges(); int fileCount = db.Attachments .Where(w => w.AttachmentReferenceId == newUpload.AssignmentUploadId && w.AttachmentReferenceType == AttachmentReferenceTypes.ASSIGNMENT_UPLOADS) .Count(); if (Request.Files.Count > 0) { for (int i = 0; i < files.Count; i++) { HttpPostedFileBase file = files[i]; string fname; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = file.FileName; } string[] find = fname.Split('.'); string extention = find[find.Length - 1]; fname = newUpload.Assignment.AssignmentName + "_upload_auid_" + newUpload.AssignmentUploadId + "_" + (i + fileCount) + "." + extention; // Get the complete folder path and store the file inside it. var finalName = Path.Combine(Server.MapPath("~/Uploads/"), fname); file.SaveAs(finalName); // Create attachment Attachment attachment = new Attachment(); attachment.AttachmentName = fname; attachment.AttachmentUrl = "/Uploads/" + fname; attachment.AttachmentReferenceType = AttachmentReferenceTypes.ASSIGNMENT_UPLOADS; attachment.AttachmentReferenceId = newUpload.AssignmentUploadId; attachment.AttachmentFileSize = file.ContentLength; db.Attachments.Add(attachment); db.SaveChanges(); } } } return(Redirect("/Student/Assignments")); }