public ActionResult DeleteConfirmed(int id) { AspNetProject aspNetProject = db.AspNetProjects.Find(id); db.AspNetProjects.Remove(aspNetProject); db.SaveChanges(); return(RedirectToAction("Index")); }
public FileResult downloadProjectFile(int id) { AspNetProject Project = db.AspNetProjects.Find(id); var filepath = System.IO.Path.Combine(Server.MapPath("~/Content/StudentProjects/"), Project.FileName); return(File(filepath, MimeMapping.GetMimeMapping(filepath), Project.FileName)); }
public ActionResult Edit([Bind(Include = "PojectId,BusinessId,Name,Description,Preview")] AspNetProject aspNetProject) { if (ModelState.IsValid) { db.Entry(aspNetProject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aspNetProject)); }
public ActionResult Create([Bind(Include = "BusinessId,Name,Description,Preview")] AspNetProject aspNetProject) { if (ModelState.IsValid) { db.AspNetProjects.Add(aspNetProject); db.SaveChanges(); return(RedirectToAction("MyProjects")); } return(View(aspNetProject)); }
public ActionResult Edit([Bind(Include = "Id,Title,Description,PublishDate,DueDate,FileName,AcceptSubmission,SubjectID")] AspNetProject aspNetProject) { if (ModelState.IsValid) { db.Entry(aspNetProject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassID = new SelectList(db.AspNetClasses, "Id", "ClassName"); ViewBag.SubjectID = new SelectList(db.AspNetSubjects, "Id", "SubjectName", aspNetProject.SubjectID); return(View(aspNetProject)); }
// GET: AspNetProject/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AspNetProject aspNetProject = db.AspNetProjects.Find(id); if (aspNetProject == null) { return(HttpNotFound()); } return(View(aspNetProject)); }
// GET: AspNetProject/Edit/5` public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AspNetProject aspNetProject = db.AspNetProjects.Find(id); if (aspNetProject == null) { return(HttpNotFound()); } ViewBag.SubjectID = new SelectList(db.AspNetSubjects, "Id", "SubjectName", aspNetProject.SubjectID); return(View(aspNetProject)); }
/// <summary> /// Fetches project details by id /// </summary> /// <param name="projectId"></param> /// <returns>Single Project Entity</returns> public ProjectEntity GetProjectById(string projectId) { AspNetProject rp = _unitOfWork.ProjectRepository.GetByID(projectId); ProjectEntity ep = new ProjectEntity(); //AspNetProject to EntityProject mapping ep.Id = rp.Id; ep.Title = rp.Title; ep.Topic = rp.Topic; ep.DateCreated = rp.DateCreated; ep.DateModified = rp.DateModified; ep.AuthorId = rp.AuthorId; ep.FullText = rp.FullText; return(ep); }
// GET: AspNetProject/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AspNetProject aspNetProject = db.AspNetProjects.Find(id); if (aspNetProject == null) { return(HttpNotFound()); } ViewBag.ClassID = new SelectList(db.AspNetSubjects.Where(x => x.TeacherID == TeacherID).Select(x => x.AspNetClass).Distinct(), "Id", "ClassName"); ViewBag.SubjectID = new SelectList(db.AspNetSubjects, "Id", "SubjectName"); return(View(aspNetProject)); }
/// <summary> /// Creates a project /// </summary> /// <param name="projectEntity"></param> /// <returns></returns> public string CreateProject(ProjectEntity projectEntity) { using (var scope = new TransactionScope()) { var project = new AspNetProject { Id = System.Guid.NewGuid().ToString(), AuthorId = projectEntity.AuthorId, Title = projectEntity.Title, Published = projectEntity.Published, Topic = projectEntity.Topic, Summary = projectEntity.Summary, FullText = projectEntity.FullText, DateCreated = projectEntity.DateCreated, DateModified = projectEntity.DateModified }; _unitOfWork.ProjectRepository.Insert(project); _unitOfWork.Save(); scope.Complete(); return(project.Id); } }
public ActionResult Create(AspNetProject aspNetProject) { HttpPostedFileBase file = Request.Files["attachment"]; if (ModelState.IsValid) { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/Projects"), fileName); file.SaveAs(path); aspNetProject.FileName = fileName; } else { aspNetProject.FileName = "-/-"; } if (db.AspNetProjects.Where(x => x.FileName == aspNetProject.FileName).Count() > 0) { TempData["Error"] = "Document already exists kindly change document name"; return(RedirectToAction("Create")); } else { db.AspNetProjects.Add(aspNetProject); db.SaveChanges(); } int ProjectID = db.AspNetProjects.Max(x => x.Id); List <string> StudentIDs = db.AspNetStudent_Subject.Where(s => s.SubjectID == aspNetProject.SubjectID).Select(s => s.StudentID).ToList(); foreach (var item in StudentIDs) { AspNetStudent_Project student_project = new AspNetStudent_Project(); student_project.StudentID = item; student_project.ProjectID = ProjectID; student_project.SubmissionStatus = false; student_project.SubmittedFileName = "-/-"; db.AspNetStudent_Project.Add(student_project); db.SaveChanges(); } /////////////////////////////////////////////////NOTIFICATION///////////////////////////////////// var NotificationObj = new AspNetNotification(); NotificationObj.Description = aspNetProject.Description; NotificationObj.Subject = aspNetProject.Title; NotificationObj.SenderID = User.Identity.GetUserId(); NotificationObj.Time = DateTime.Now; NotificationObj.Url = "/AspNetProject/Details/" + aspNetProject.Id; db.AspNetNotifications.Add(NotificationObj); db.SaveChanges(); var NotificationID = db.AspNetNotifications.Max(x => x.Id); var students = db.AspNetStudent_Project.Where(sp => sp.ProjectID == aspNetProject.Id).Select(x => x.StudentID).ToList(); var users = new List <String>(); foreach (var item in students) { var parentID = db.AspNetParent_Child.Where(x => x.ChildID == item).Select(x => x.ParentID).FirstOrDefault(); users.Add(parentID); } var allusers = users.Union(students); foreach (var receiver in allusers) { var notificationRecieve = new AspNetNotification_User(); notificationRecieve.NotificationID = NotificationID; notificationRecieve.UserID = Convert.ToString(receiver); notificationRecieve.Seen = false; db.AspNetNotification_User.Add(notificationRecieve); db.SaveChanges(); } /////////////////////////////////////Email///////////////////////////////////////// var subject = db.AspNetSubjects.Where(x => x.Id == aspNetProject.SubjectID).Select(x => x.SubjectName).FirstOrDefault(); var StudentEmail = db.AspNetStudent_Project.Where(sp => sp.ProjectID == aspNetProject.Id).Select(x => x.StudentID).ToList(); var StudentRoll = db.AspNetStudent_Project.Where(sp => sp.ProjectID == aspNetProject.Id).Select(x => x.AspNetUser.UserName).ToList(); string[] studentRollList = new string[StudentRoll.Count]; int c = 0; foreach (var item in StudentRoll) { studentRollList[c] = item; c++; } var StudentName = db.AspNetStudent_Project.Where(sp => sp.ProjectID == aspNetProject.Id).Select(x => x.AspNetUser.Name).ToList(); string[] studentNamelist = new string[StudentName.Count]; int i = 0; foreach (var item in StudentName) { studentNamelist[i] = item; i++; } var Users = new List <String>(); foreach (var item in StudentEmail) { Users.Add(db.AspNetParent_Child.Where(x => x.ChildID == item).Select(x => x.ParentID).FirstOrDefault()); } //Message start //var classe = db.AspNetClasses.Where(p => p.Id == aspNetHomework.ClassId).FirstOrDefault(); Utility obj = new Utility(); obj.SMSToOffitialsp("Dear Principal, Project has been assigned. IPC NGS Preschool, Aziz Avenue, Lahore."); obj.SMSToOffitialsa("Dear Admin, Project has been assigned. IPC NGS Preschool, Aziz Avenue, Lahore."); AspNetMessage oob = new AspNetMessage(); oob.Message = "Dear Parents, The thematic project has been assigned to your child on portal. IPC NGS Preschool, Aziz Avenue, Lahore.";// Title : " + aspNetProject.Title + ", For discription login to Portal please - obj.SendSMS(oob, Users); //Message end List <string> EmailList = new List <string>(); foreach (var sender in Users) { EmailList.Add(db.AspNetUsers.Where(x => x.Id == sender).Select(x => x.Email).FirstOrDefault()); } var j = 0; foreach (var toEmail in EmailList) { try { NotificationObj.Subject = studentNamelist[j] + "(" + studentRollList[j] + ") " + " Subject:" + subject + " Title:" + aspNetProject.Title; j++; string senderEmail = System.Configuration.ConfigurationManager.AppSettings["SenderEmail"].ToString(); string senderPassword = System.Configuration.ConfigurationManager.AppSettings["SenderPassword"].ToString(); SmtpClient client = new SmtpClient("smtpout.secureserver.net", 25); client.EnableSsl = false; client.Timeout = 100000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(senderEmail, senderPassword); MailMessage mailMessage = new MailMessage(senderEmail, toEmail, NotificationObj.Subject, NotificationObj.Description); mailMessage.CC.Add(new MailAddress(senderEmail)); mailMessage.IsBodyHtml = true; mailMessage.BodyEncoding = UTF8Encoding.UTF8; client.Send(mailMessage); } catch (Exception ex) { } } return(RedirectToAction("Index")); } ViewBag.ClassID = new SelectList(db.AspNetClasses.Where(x => x.SessionID == SessionID), "Id", "ClassName"); ViewBag.SubjectID = new SelectList(db.AspNetSubjects.Where(x => x.AspNetClass.SessionID == SessionID), "Id", "SubjectName", aspNetProject.SubjectID); TempData["Create"] = "Project has been created"; return(View(aspNetProject)); }