public ActionResult Details(string id, string mark01, string mark02, string mark03, string mark04, string mark05, string mark06, string mark07, string mark08, string mark09, string mark10) { var ans = db.Answer_tbl.Find(id); var st = db.Student_tbl.Find(ans.Stu_Code); if (st != null) { var res = db.Result_tbl.Where(m => m.StudentID == st.ID && m.Exam_ID == ans.Exam_ID).FirstOrDefault(); if (ans.Ans_6 == null && ans.Ans_7 == null) { res.Achieved_Mark = int.Parse(mark01) + int.Parse(mark02) + int.Parse(mark03) + int.Parse(mark04) + int.Parse(mark05); } else { res.Achieved_Mark = int.Parse(mark01) + int.Parse(mark02) + int.Parse(mark03) + int.Parse(mark04) + int.Parse(mark05) + int.Parse(mark06) + int.Parse(mark07) + int.Parse(mark08) + int.Parse(mark09) + int.Parse(mark10); } db.Entry(res).State = EntityState.Modified; db.SaveChanges(); } //Add notification return(RedirectToAction("Create", "Notification", new { mthd = "Index", cntlr = "Result", course_id = ans.Exam_ID, subject = "New Result is added for Course ", role_not = "Student" })); //return RedirectToAction("Index", "Result"); }
public void deleteEmployeeLeave(int employeeleaveId) { var isLeave = _dbcontext.EmployeeLeaves.Where(l => l.EmployeeleaveID == employeeleaveId).FirstOrDefault(); if (isLeave != null) { _dbcontext.Entry(isLeave).State = System.Data.Entity.EntityState.Deleted; _dbcontext.SaveChanges(); } }
public ActionResult Edit(Question_tbl question_tbl) { if (ModelState.IsValid) { db.Entry(question_tbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(question_tbl)); }
public ActionResult UploadImage(string id, FileDataVM model) { if (!ModelState.IsValid) { return(View(model)); } byte[] uploadedFile = new byte[model.File.InputStream.Length]; model.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length); // now you could pass the byte array to your model and store wherever // you intended to store it var art = db.Lecturer_tbl.Find(id); art.Image = uploadedFile; db.Entry(art).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = id })); }
public ActionResult Edit([Bind(Include = "ID,Title,Description,ReleaseDate,Type,Ed_Level,CourseID")] Event_tbl event_tbl) { if (ModelState.IsValid) { db.Entry(event_tbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Course_tbl, "ID", "Name", event_tbl.CourseID); return(View(event_tbl)); }
public ActionResult Edit(Course_tbl course_tbl) { if (ModelState.IsValid) { db.Entry(course_tbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Prof = new SelectList(db.Lecturer_tbl.Where(m => m.Role == "Prof"), "ID", "Name"); ViewBag.Assistant = new SelectList(db.Lecturer_tbl.Where(m => m.Role == "Assistant"), "ID", "Name"); return(View(course_tbl)); }
public ActionResult Edit(Exam_tbl exam_tbl) { if (ModelState.IsValid) { var question = new List <Question_tbl>(); if (exam_tbl.Type == "Quiz") { exam_tbl.Q06 = null; exam_tbl.Q07 = null; exam_tbl.Q08 = null; exam_tbl.Q09 = null; exam_tbl.Q10 = null; question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q01).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q02).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q03).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q04).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q05).FirstOrDefault()); } else { question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q01).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q02).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q03).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q04).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q05).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q06).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q07).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q08).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q09).FirstOrDefault()); question.Add(db.Question_tbl.Where(q => q.Q_ID == exam_tbl.Q10).FirstOrDefault()); } // Adding total mark of each question to the exam exam_tbl.Total_Mark = 0; for (int i = 0; i < question.Count; i++) { exam_tbl.Total_Mark += question[i].Total_Mark; } db.Entry(exam_tbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Q01 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q01); ViewBag.Q02 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q02); ViewBag.Q03 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q03); ViewBag.Q04 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q04); ViewBag.Q05 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q05); ViewBag.Q06 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q06); ViewBag.Q07 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q07); ViewBag.Q08 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q08); ViewBag.Q09 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q09); ViewBag.Q10 = new SelectList(db.Question_tbl, "Q_ID", "Ques_Title", exam_tbl.Q10); ViewBag.Course_ID = new SelectList(db.Course_tbl, "ID", "Name", exam_tbl.Course_ID); return(View(exam_tbl)); }
public ActionResult Edit([Bind(Include = "Id,Title,Author,Tag,Image,Year_of_publishing")] BookTbl bookTbl) { try { if (ModelState.IsValid) { db.Entry(bookTbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception e) { } return(View("Edit", bookTbl)); }
public ActionResult Edit(RegisteredCourses_tbl registeredCourses_tbl) { if (ModelState.IsValid) { //if (registeredCourses_tbl.Course01 != null) //{ // registeredCourses_tbl.Course01 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course01).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course02 != null) //{ // registeredCourses_tbl.Course02 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course02).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course03 != null) //{ // registeredCourses_tbl.Course03 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course03).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course04 != null) //{ // registeredCourses_tbl.Course04 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course04).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course05 != null) //{ // registeredCourses_tbl.Course05 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course05).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course06 != null) //{ // registeredCourses_tbl.Course06 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course06).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course07 != null) //{ // registeredCourses_tbl.Course07 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course07).FirstOrDefault().ID; //} //------ db.Entry(registeredCourses_tbl).State = EntityState.Modified; db.SaveChanges(); EditAttendance(registeredCourses_tbl); return(RedirectToAction("Details", "Student", new { id = registeredCourses_tbl.ID })); } ViewBag.Course01 = new SelectList(db.Course_tbl, "ID", "Name", registeredCourses_tbl.Course01); ViewBag.Course02 = new SelectList(db.Course_tbl, "ID", "Name", registeredCourses_tbl.Course02); ViewBag.Course03 = new SelectList(db.Course_tbl, "ID", "Name", registeredCourses_tbl.Course03); ViewBag.Course04 = new SelectList(db.Course_tbl, "ID", "Name", registeredCourses_tbl.Course04); ViewBag.Course05 = new SelectList(db.Course_tbl, "ID", "Name", registeredCourses_tbl.Course05); ViewBag.Course06 = new SelectList(db.Course_tbl, "ID", "Name", registeredCourses_tbl.Course06); ViewBag.Course07 = new SelectList(db.Course_tbl, "ID", "Name", registeredCourses_tbl.Course07); return(View(registeredCourses_tbl)); }
public IHttpActionResult PutAttendance_tbl() { if (!ModelState.IsValid) { return(BadRequest("This is the invaild part")); } // =================================== Send Json data in request body ====================== var bodyStream = new StreamReader(HttpContext.Current.Request.InputStream); //bodyStream.BaseStream.Seek(0, SeekOrigin.Begin); var bodyText = bodyStream.ReadToEnd(); //=================================== Save JSON data in file in server ===================== string fname = "h:\\root\\home\\phicommsees-001\\www\\db\\jsonfiles\\path.json"; System.IO.File.WriteAllText(fname, bodyText); //Save file on server //fname = @"D:\path.json"; //postedFile.SaveAs(fname); var json = File.ReadAllText(fname); var Att_VM = JsonConvert.DeserializeObject <AttVM>(json); for (int i = 0; i < Att_VM.StudentID.Length; i++) { var std_ID = Att_VM.StudentID[i]; var attendance_tbl = db.Attendance_tbl.Where(s => s.CourseID == Att_VM.CourseID && s.StudentID == std_ID).FirstOrDefault(); if (attendance_tbl != null) { attendance_tbl.No_of_Attendances += 1; db.Entry(attendance_tbl).State = EntityState.Modified; db.SaveChanges(); } } //========================== JSON File ==================================================== //if (HttpContext.Current.Request.Files.Count == 0) // throw new HttpResponseException(new HttpResponseMessage() // { // ReasonPhrase = "Files are required", // StatusCode = HttpStatusCode.BadRequest // }); //foreach (string file in HttpContext.Current.Request.Files) //{ // string fname; // var postedFile = HttpContext.Current.Request.Files[file]; // fname = postedFile.FileName; // if (!(postedFile.ContentType == "application/json" || postedFile.ContentType == "application/xml")) // { // throw new System.Web.Http.HttpResponseException(new HttpResponseMessage() // { // ReasonPhrase = "Wrong content type", // StatusCode = HttpStatusCode.BadRequest // }); // } // // =================================== JSON File =========================================== // //Save file on server // fname = "h:\\root\\home\\phicommsees-001\\www\\db\\jsonfiles\\" + fname; // postedFile.SaveAs(fname); // var json = File.ReadAllText(fname); // var Att_VM = JsonConvert.DeserializeObject<AttVM>(json); // for(int i = 0; i < Att_VM.StudentID.Length; i++) // { // var std_ID = Att_VM.StudentID[i]; // var attendance_tbl = db.Attendance_tbl.Where(s => s.CourseID == Att_VM.CourseID && s.StudentID == std_ID).FirstOrDefault(); // if(attendance_tbl != null) // { // attendance_tbl.No_of_Attendances += 1; // db.Entry(attendance_tbl).State = EntityState.Modified; // db.SaveChanges(); // } // } //} return(StatusCode(HttpStatusCode.Accepted)); }