public ActionResult SchoolComplainReply(tbl_ClientorSchoorComplainValidation sa, int id) { try { int userid = Convert.ToInt32((Session["Ad"])); var com = db.Client_SchoolComplain.FirstOrDefault(m => m.complain_Id == id); if (com != null) { com.UserId = userid; com.RoleId = 2; com.complain_Id = id; com.replymsg = sa.replymsg; db.Entry(com).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Submitted"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(View()); }
public ActionResult viewStudentComplainReply(tblStudentComplainValidation sa, int id) { try { int user = Convert.ToInt32((Session["school"])); var com = db.StudentComplains.FirstOrDefault(m => m.complain_id == id); if (com != null) { com.ReplyMsg = sa.ReplyMsg; db.Entry(com).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Submitted"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("viewStudentComplainform")); }
public ActionResult updateAnnouncement(Announcement anno, int id) { try { int userid = Convert.ToInt32(Session["Ad"]); var data = db.Announcements.Where(x => x.Announcement_Id == id).First(); if (data != null) { data.Announcement_Id = id; data.Announcement_Title = anno.Announcement_Title; data.Announcement_Body = anno.Announcement_Body; data.CreatedDate = DateTime.Now; data.RoleId = 1; data.UserId = userid; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Updated"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("viewAnouncement", "Announcement")); }
public ActionResult updateLearningTip(TechnicTip dat, int id) { try { var data = db.TechnicTips.Where(x => x.tipsId == id).First(); if (data != null) { data.Title = dat.Title; data.VedioPath = dat.VedioPath; data.shortDes = dat.shortDes; data.longDes = dat.longDes; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Updated"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("viewLearning", "LearningTips")); }
public ActionResult updatekidTalent(KidTalent dat, int id) { try { var data = db.KidTalents.Where(x => x.telentId == id).First(); if (data != null) { data.Title = dat.Title; data.VedioPath = dat.VedioPath; data.shortDes = dat.shortDes; data.LongDes = dat.LongDes; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Updated"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("viewKidTalent", "kidTalent")); }
public JsonResult SaveAssignCourse(CourseAssignToTeacher assignCourse) { var asignCoursesList = db.CourseAssignToTeachers.Where(t => t.courseId == assignCourse.courseId && t.Course.Status == true).ToList(); if (asignCoursesList.Count > 0) { return(Json(false)); } else { int schoolid = Convert.ToInt32(Session["school"]); assignCourse.School_Id = schoolid; db.CourseAssignToTeachers.Add(assignCourse); db.SaveChanges(); var teacher = db.Teachers.FirstOrDefault(t => t.Id == assignCourse.TeacherId); var course = db.Courses.FirstOrDefault(t => t.courseId == assignCourse.courseId); if (course != null) { course.Status = true; course.AssignTo = teacher.Name; db.Entry(course).State = EntityState.Modified; //db.Courses.Add(course); db.SaveChanges(); return(Json(true)); } else { return(Json(false)); } //return Json(false); } }
public ActionResult ApproveArticleClient(int id, string submit) { switch (submit) { case "Approve": using (Digital_SchoolEntities2 entities = new Digital_SchoolEntities2()) { var item = entities.Articles.Single(x => x.ArticleId == id); item.statusId = 2; entities.Articles.Attach(item); entities.Entry(item).Property(X => X.statusId).IsModified = true; entities.SaveChanges(); return(RedirectToAction("Clientapprovalarticle")); break; } case "Reject": using (Digital_SchoolEntities2 entities = new Digital_SchoolEntities2()) { var item = entities.Articles.Single(x => x.ArticleId == id); item.statusId = 3; entities.Articles.Attach(item); entities.Entry(item).Property(X => X.statusId).IsModified = true; entities.SaveChanges(); return(RedirectToAction("Clientapprovalarticle")); break; } default: throw new Exception(); break; } return(View()); }
public JsonResult UnallocateAllRooms(bool name) { int schoolid = Convert.ToInt32(Session["school"]); var roomInfo = db.TimeTables.Where(r => r.AllocationStatus == "Allocated" && r.SchoolId == schoolid).ToList(); if (roomInfo.Count == 0) { return(Json(false)); } else { foreach (var room in roomInfo) { room.AllocationStatus = null; db.Entry(room).State = EntityState.Modified; db.SaveChanges(); } return(Json(true)); } }
public ActionResult updateAnnouncement(Announcement dat, int id) { try { var data = db.Announcements.Where(x => x.Announcement_Id == id).First(); if (data != null) { db.Entry(data).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Updated"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("ViewAnnouncement", "Announcement")); }
public ActionResult updateClass(Tbl_Class dat, int id) { try { var data = db.Tbl_Class.Where(x => x.Class_Id == id).First(); if (data != null) { data.Name = dat.Name; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Updated"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("viewsClass", "Class")); }
public ActionResult ProfileSetting(tbl_StudentValidation sa) { if (Session["Student"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } try { tbl_StudentValidation student = new tbl_StudentValidation(); int userid = Convert.ToInt32((Session["Student"])); var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); if (ModelState.IsValid) { if (sa.UserImageFIle != null) { if (l != null) { Session["StudentName"] = sa.Name; l.UserId = userid; l.Name = sa.Name; l.Password = sa.Password; l.Email = sa.Email; l.RoleID = 4; db.Entry(l).State = EntityState.Modified; db.SaveChanges(); } string filename = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName); string extension = Path.GetExtension(sa.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; student.Image = "~/FrontEnd/Images/StudentImage/" + filename; student.Name = sa.Name; student.Email = sa.Email; student.Password = sa.Password; student.Id = userid; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (sa.UserImageFIle.ContentLength <= 1000000) { db.Entry(student).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/StudentImage/"), filename); sa.UserImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("ProfileSetting")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { student.Image = Session["imgPath"].ToString(); if (l != null) { Session["name"] = sa.Name; l.UserId = userid; l.Name = sa.Name; l.Password = sa.Password; l.Email = sa.Email; l.RoleID = 4; db.Entry(l).State = EntityState.Modified; db.SaveChanges(); } student.Name = sa.Name; student.Email = sa.Email; student.Password = sa.Password; student.Id = userid; db.Entry(student).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("ProfileSetting")); } } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult register(tbl_ClientValidation uv, string tabButton, HttpPostedFileBase imgInp) { try { Client c = new Client(); int latestclientid = 0; if (tabButton.Equals("next")) { c.UserName = uv.UserName; //c.FatherName = uv.FatherName; c.CreatedOn = DateTime.Now; c.Email = uv.Email; c.Password = uv.Password; c.ConfirmPassword = uv.ConfirmPassword; c.Cnic = uv.Cnic; c.Contact_No = uv.Contact_No; c.status = 1; c.Gender = uv.Gender; db.Clients.Add(c); db.SaveChanges(); latestclientid = c.UserId; Session["Latestclientid"] = latestclientid; //ViewBag.Message = "Data Submitted"; Session["btn"] = "1"; } else if (tabButton.Equals("finish")) { if (imgInp != null) { string filename = Path.GetFileNameWithoutExtension(imgInp.FileName); string extension = Path.GetExtension(imgInp.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; //c.Image = "~/Content/img/users/" + filename; filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/ClientReg/"), filename); imgInp.SaveAs(filename); int id = Convert.ToInt32(Session["Latestclientid"]); var item = db.Clients.Single(x => x.UserId == id); item.Image = "~/FrontEnd/Images/ClientReg/" + filename; db.Clients.Attach(item); db.Entry(item).Property(X => X.Image).IsModified = true; db.SaveChanges(); ModelState.Clear(); } } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(View()); }
public ActionResult ProfileSetting(tbl_schoolValidation sa) { School school = new School(); try { //loginTable l = new loginTable(); int userid = Convert.ToInt32((Session["school"])); var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); //if (ModelState.IsValid) //{ if (sa.UserImageFIle != null) { if (l != null) { Session["schoolName"] = sa.School_Name; l.UserId = userid; l.Name = sa.School_Name; l.Password = sa.Password; l.Email = sa.School_Email; l.RoleID = 2; db.Entry(l).State = EntityState.Modified; db.SaveChanges(); } string filename = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName); string extension = Path.GetExtension(sa.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; school.School_Address = sa.School_Address; school.School_Image = "~/FrontEnd/Images/SchoolImage/" + filename; school.School_Name = sa.School_Name; school.School_Contactno = sa.School_Contactno; school.School_Email = sa.School_Email; school.Password = sa.Password; school.School_Id = userid; school.CreatedOn = Convert.ToDateTime(Session["DateCreated"]); if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (sa.UserImageFIle.ContentLength <= 1000000) { db.Entry(school).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/SchoolImage/"), filename); sa.UserImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("ProfileSetting")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { school.School_Image = Session["imgPath"].ToString(); if (l != null) { Session["schoolName"] = sa.School_Name; l.UserId = userid; l.Name = sa.School_Name; l.Password = sa.Password; l.Email = sa.School_Email; l.RoleID = 2; db.Entry(l).State = EntityState.Modified; db.SaveChanges(); } school.School_Name = sa.School_Name; school.School_Email = sa.School_Email; school.Password = sa.Password; school.CreatedOn = Convert.ToDateTime(Session["DateCreated"]); school.School_Contactno = sa.School_Contactno; school.School_Address = sa.School_Address; school.School_Id = userid; db.Entry(school).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("ProfileSetting")); } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult updateArticle(tbl_ArticleValidation sa, int id) { if (Session["Ad"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } List <ArticleType> list = db.ArticleTypes.ToList(); ViewBag.articletypelist = new SelectList(list, "Article_TypeId", "Article_Typename "); try { Article art = new Article(); //int userid = Convert.ToInt32((Session["Ad"])); //var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); if (sa.UserImageFIle != null) { //if (l != null) //{ // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} string filename = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName); string extension = Path.GetExtension(sa.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; art.imgPath = "~/FrontEnd/Images/ArticleImage/" + filename; art.ArticleId = id; art.Article_TypeId = sa.Article_TypeId; art.Role_Id = Convert.ToInt32(Session["RoleId"]); art.UserId = Convert.ToInt32(Session["Ad"]); art.Title = sa.Title; art.shortDes = sa.shortDes; art.statusId = 2; art.longDes = sa.longDes; art.CreatedDate = DateTime.Now; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (sa.UserImageFIle.ContentLength <= 1000000) { db.Entry(art).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/ArticleImage/"), filename); sa.UserImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("viewArticle")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { art.imgPath = Session["imgPath"].ToString(); //if (l != null) //{ // Session["name"] = sa.ad_name; // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} //superadmin.ad_name = sa.ad_name; //superadmin.ad_email = sa.ad_email; //superadmin.ad_password = sa.password; //superadmin.ad_Id = userid; art.ArticleId = id; art.Article_TypeId = sa.Article_TypeId; art.Role_Id = Convert.ToInt32(Session["RoleId"]); art.Title = sa.Title; art.shortDes = sa.shortDes; art.statusId = 2; art.longDes = sa.longDes; art.UserId = Convert.ToInt32(Session["Ad"]); art.CreatedDate = DateTime.Now; db.Entry(art).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("viewArticle")); } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult updateTeam(tbl_addTeam sa, int id) { if (Session["Ad"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } List <Department> list = db.Departments.ToList(); ViewBag.departmentList = new SelectList(list, "Department_ID", "Department_Name"); try { Team tea = new Team(); //int userid = Convert.ToInt32((Session["Ad"])); //var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); if (sa.UserImageFIle != null) { //if (l != null) //{ // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} string filename = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName); string extension = Path.GetExtension(sa.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; tea.Image = "~/FrontEnd/Images/DepartmentImage/" + filename; tea.Team_Id = id; tea.Designation = sa.Designation; tea.Long_Description = sa.Long_Description; tea.Short_Description = sa.Short_Description; tea.Department_ID = sa.Department_ID; tea.Name = sa.Name; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (sa.UserImageFIle.ContentLength <= 1000000) { db.Entry(tea).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/DepartmentImage/"), filename); sa.UserImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("ViewTeam")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { tea.Image = Session["imgPath"].ToString(); //if (l != null) //{ // Session["name"] = sa.ad_name; // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} //superadmin.ad_name = sa.ad_name; //superadmin.ad_email = sa.ad_email; //superadmin.ad_password = sa.password; //superadmin.ad_Id = userid; tea.Team_Id = id; tea.Designation = sa.Designation; tea.Long_Description = sa.Long_Description; tea.Short_Description = sa.Short_Description; tea.Department_ID = sa.Department_ID; tea.Name = sa.Name; db.Entry(tea).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("ViewTeam")); } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult updatecourse(tbl_coursevalidation sa, int id) { if (Session["Ad"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } try { Course cc = new Course(); //int userid = Convert.ToInt32((Session["Ad"])); //var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); if (sa.CourseImageFIle != null) { //if (l != null) //{ // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} string filename = Path.GetFileNameWithoutExtension(sa.CourseImageFIle.FileName); string extension = Path.GetExtension(sa.CourseImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; cc.imageLink = "~/FrontEnd/Images/CourseImage/" + filename; sa.Role_Id = Convert.ToInt32(Session["RoleId"]); sa.User_Id = Convert.ToInt32(Session["Ad"]); cc.courseId = id; cc.User_Id = sa.User_Id; cc.Role_Id = sa.Role_Id; cc.CreatedDate = DateTime.Now; cc.courseDescription = sa.courseDescription; cc.courseName = sa.courseName; cc.courseType = sa.courseType; cc.Code = sa.Code; cc.VideoLink = sa.VideoLink; cc.longDes = sa.longDes; cc.duration = sa.duration; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (sa.CourseImageFIle.ContentLength <= 1000000) { db.Entry(cc).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/CourseImage/"), filename); sa.CourseImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("ViewCourse")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { cc.imageLink = Session["imgPath"].ToString(); //if (l != null) //{ // Session["name"] = sa.ad_name; // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} //superadmin.ad_name = sa.ad_name; //superadmin.ad_email = sa.ad_email; //superadmin.ad_password = sa.password; //superadmin.ad_Id = userid; sa.Role_Id = Convert.ToInt32(Session["RoleId"]); sa.User_Id = Convert.ToInt32(Session["Ad"]); cc.courseId = id; cc.User_Id = sa.User_Id; cc.Role_Id = sa.Role_Id; cc.CreatedDate = DateTime.Now; cc.courseDescription = sa.courseDescription; cc.courseName = sa.courseName; cc.courseType = sa.courseType; cc.Code = sa.Code; cc.VideoLink = sa.VideoLink; cc.longDes = sa.longDes; cc.duration = sa.duration; db.Entry(cc).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("ViewCourse")); } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult updateLacture(Lecture mt, HttpPostedFileBase file) { try { if (!(file.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessing" || file.ContentType == "application/msword" || file.ContentType == "application/pdf")) { ViewBag.Message = "Select Doc or Docx or Pdf extention file only"; return(View()); } else { int teacherid = Convert.ToInt32(Session["Teacher"]); //var model = db.ManualTests.Find(mt.TestId); string oldfilePath = Session["url"].ToString(); if (file != null && file.ContentLength > 0) { string fileName = Guid.NewGuid() + Path.GetExtension(file.FileName); file.SaveAs(Path.Combine(Server.MapPath("~/FrontEnd/File_upload/Lecture/"), fileName)); mt.LectureUrl = fileName; string fullPath = Request.MapPath(oldfilePath); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } mt.CreatedDate = DateTime.Now; db.Entry(mt).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("viewuploadLecture")); } else { ViewBag.Message = "Not Valid File Type"; return(RedirectToAction("viewuploadLecture")); } } //} else { mt.LectureUrl = Session["url"].ToString(); mt.UserId = teacherid; //mt.CourseId = model.CourseId; //mt.ClassId = model.ClassId; //mt.SchoolId = model.SchoolId; mt.CreatedDate = DateTime.Now; //db.Entry(mt).EntityState = EntityState.Detached; db.Entry(mt).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("viewuploadLecture")); } } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult updateTeacher(tbl_TeacherValidation tea, int id) { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.school = new SelectList(list, "Class_Id", "Name"); tea.Reg_No = RegNo(tea); try { digital_School.Models.Teacher a = new digital_School.Models.Teacher(); //int userid = Convert.ToInt32((Session["Ad"])); //var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); if (tea.UserImageFIle != null) { //if (l != null) //{ // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} string filename = Path.GetFileNameWithoutExtension(tea.UserImageFIle.FileName); string extension = Path.GetExtension(tea.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; a.Image = "~/FrontEnd/Images/TeacherImage/" + filename; a.Id = id; a.Class_Id = tea.Class_Id; a.School_Id = Convert.ToInt32(Session["school"]); a.Name = tea.Name; a.Reg_No = tea.Reg_No; a.Address = tea.Address; a.Email = tea.Email; a.Contact = tea.Contact; a.Password = tea.Password; a.JoiningDate = DateTime.Now; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (tea.UserImageFIle.ContentLength <= 1000000) { db.Entry(a).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/TeacherImage/"), filename); tea.UserImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("viewsteacher")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { a.Image = Session["imgPath"].ToString(); //if (l != null) //{ // Session["name"] = sa.ad_name; // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} //superadmin.ad_name = sa.ad_name; //superadmin.ad_email = sa.ad_email; //superadmin.ad_password = sa.password; //superadmin.ad_Id = userid; a.Id = id; a.Class_Id = tea.Class_Id; a.School_Id = Convert.ToInt32(Session["school"]); a.Name = tea.Name; a.Reg_No = tea.Reg_No; a.Address = tea.Address; a.Email = tea.Email; a.Contact = tea.Contact; a.Password = tea.Password; a.JoiningDate = DateTime.Now; db.Entry(a).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("viewsteacher")); } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult updateArticle(tbl_eventValidation sa, int id) { if (Session["Ad"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } try { Event ev = new Event(); //int userid = Convert.ToInt32((Session["Ad"])); //var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); if (sa.UserImageFIle != null) { //if (l != null) //{ // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} string filename = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName); string extension = Path.GetExtension(sa.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; ev.Event_VenueImage = "~/FrontEnd/Images/EventImage/" + filename; ev.EventId = id; ev.Title = sa.Title; ev.Event_Description = sa.Event_Description; ev.Event_End_Date = sa.Event_End_Date; ev.Event_Start_Date = sa.Event_Start_Date; ev.Event_End_Time = sa.Event_End_Time; ev.Event_Start_Time = sa.Event_Start_Time; ev.Event_Venue = sa.Event_Venue; ev.Event_VenueVideo = sa.Event_VenueVideo; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (sa.UserImageFIle.ContentLength <= 1000000) { db.Entry(ev).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/EventImage/"), filename); sa.UserImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("viewsevent")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { ev.Event_VenueImage = Session["imgPath"].ToString(); //if (l != null) //{ // Session["name"] = sa.ad_name; // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} //superadmin.ad_name = sa.ad_name; //superadmin.ad_email = sa.ad_email; //superadmin.ad_password = sa.password; //superadmin.ad_Id = userid; ev.EventId = id; ev.Title = sa.Title; ev.Event_Description = sa.Event_Description; ev.Event_End_Date = sa.Event_End_Date; ev.Event_Start_Date = sa.Event_Start_Date; ev.Event_End_Time = sa.Event_End_Time; ev.Event_Start_Time = sa.Event_Start_Time; ev.Event_Venue = sa.Event_Venue; ev.Event_VenueVideo = sa.Event_VenueVideo; db.Entry(ev).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("viewsevent")); } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }