Пример #1
0
        public ActionResult PostMessage(MessageReplyViewModel vm)
        {
            //var username = User.Identity.Name;
            //string fullName = "";
            int msgid = 0;

            int    teacherid = Convert.ToInt32(Session["Student"]);
            int    tempclassid;
            int    originalclassid;
            string Regno;
            var    getteacherid = dbContext.Students.Find(teacherid);

            tempclassid = getteacherid.Class_Id;
            Regno       = getteacherid.RegNo;
            var classid1 = dbContext.Tbl_Class.Where(x => x.Class_Id == tempclassid).SingleOrDefault();

            originalclassid = classid1.Class_Id;
            //AB enroll course wala dropdown ajayega
            CourseDBHandle gc = new CourseDBHandle();

            List <tblEnrollStudentInCourseValidation> list = gc.GetSudentEnrollCourse(Regno, originalclassid);

            ViewBag.course = new SelectList(list, "courseId", "courseName");
            int schoolid;
            int classid;

            schoolid = getteacherid.School_Id;
            classid  = getteacherid.Class_Id;

            //if (!string.IsNullOrEmpty(username))
            //{
            //    var user = dbContext.loginTables.SingleOrDefault(u => u.Name == username);
            //    fullName = string.Concat(new string[] { user.Name });
            //}
            Message messagetoPost = new Message();

            if (vm.Message.Subject != string.Empty && vm.Message.MessageToPost != string.Empty)
            {
                messagetoPost.DatePosted    = DateTime.Now;
                messagetoPost.Subject       = vm.Message.Subject;
                messagetoPost.MessageToPost = vm.Message.MessageToPost;
                messagetoPost.From          = Session["StudentName"].ToString();
                messagetoPost.Class_Id      = classid;
                messagetoPost.Role_ID       = 4;
                messagetoPost.UserId        = teacherid;
                messagetoPost.courseId      = vm.Message.courseId;


                messagetoPost.SchoolId = schoolid;
                dbContext.Messages.Add(messagetoPost);
                dbContext.SaveChanges();
                msgid = messagetoPost.Id;
            }

            return(RedirectToAction("Index", "Message", new { Id = msgid, courseid = vm.Message.courseId }));
        }
Пример #2
0
        public ActionResult PostMessage(MessageReplyViewModel vm)
        {
            int msgid = 0;

            int teacherid = Convert.ToInt32(Session["Teacher"]);

            int schoolid;
            int classid;
            var getteacherid = dbContext.Teachers.Find(teacherid);

            schoolid = getteacherid.School_Id;
            classid  = getteacherid.Class_Id;

            CourseDBHandle gc = new CourseDBHandle();
            int            tempclassid;
            int            originalclassid;

            tempclassid = getteacherid.Class_Id;
            var classid1 = dbContext.Tbl_Class.Where(x => x.Class_Id == tempclassid).SingleOrDefault();

            originalclassid = classid1.Class_Id;
            List <tbl_CourseAssigntoTeacherValidation> list = gc.GetTeacherAssignedCourse(teacherid, originalclassid);

            ViewBag.course = new SelectList(list, "courseId", "courseName");

            Message messagetoPost = new Message();

            if (vm.Message.Subject != string.Empty && vm.Message.MessageToPost != string.Empty)
            {
                messagetoPost.DatePosted = DateTime.Now;
                messagetoPost.Subject    = vm.Message.Subject;
                messagetoPost.courseId   = vm.Message.courseId;

                messagetoPost.MessageToPost = vm.Message.MessageToPost;
                messagetoPost.From          = Session["TeacherName"].ToString();
                messagetoPost.Class_Id      = classid;
                messagetoPost.Role_ID       = 3;
                messagetoPost.UserId        = teacherid;
                messagetoPost.courseId      = vm.Message.courseId;
                messagetoPost.SchoolId      = schoolid;
                dbContext.Messages.Add(messagetoPost);
                dbContext.SaveChanges();
                msgid = messagetoPost.Id;
            }

            return(RedirectToAction("Index", "Message", new { Id = msgid, courseid = vm.Message.courseId }));
        }
        public JsonResult SaveRoomSchedule(TimeTable roomAllocation)
        {
            var scheduleList = db.TimeTables.Where(t => t.SectionId == roomAllocation.SectionId && t.DayId == roomAllocation.DayId && t.AllocationStatus == "Allocated").ToList();

            if (scheduleList.Count == 0)
            {
                int schoolid = Convert.ToInt32(Session["school"]);
                roomAllocation.SchoolId         = schoolid;
                roomAllocation.AllocationStatus = "Allocated";
                db.TimeTables.Add(roomAllocation);
                db.SaveChanges();
                return(Json(true));
            }
            else
            {
                bool state = false;
                foreach (var allocation in scheduleList)
                {
                    if ((roomAllocation.StartTime >= allocation.StartTime && roomAllocation.StartTime < allocation.EndTime) ||
                        (roomAllocation.EndTime > allocation.StartTime && roomAllocation.EndTime <= allocation.EndTime) && roomAllocation.AllocationStatus == "Allocated")
                    {
                        state = true;
                    }
                }
                if (state == false)
                {
                    int schoolid = Convert.ToInt32(Session["school"]);
                    roomAllocation.SchoolId         = schoolid;
                    roomAllocation.AllocationStatus = "Allocated";
                    db.TimeTables.Add(roomAllocation);
                    db.SaveChanges();
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
        }
        public ActionResult Profile(tbl_ClientValidation sa)

        {
            Client client = new Client();

            try
            {
                //loginTable l = new loginTable();
                int userid = Convert.ToInt32((Session["Cliente"]));

                var l = db.loginTables.FirstOrDefault(t => t.UserId == userid);

                if (ModelState.IsValid)
                {
                    if (sa != null)
                    {
                        if (l != null)
                        {
                            Session["ClientName"] = sa.UserName;
                            l.UserId          = userid;
                            l.Name            = sa.UserName;
                            l.Password        = sa.Password;
                            l.Email           = sa.Email;
                            l.RoleID          = 5;
                            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;



                        client.Image    = "~/Content/img/users/" + filename;
                        client.UserName = sa.UserName;
                        client.Email    = sa.Email;
                        client.Password = sa.Password;
                        client.UserId   = userid;



                        if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
                        {
                            if (sa.UserImageFIle.ContentLength <= 1000000)
                            {
                                db.Entry(client).State = EntityState.Modified;



                                string oldImgPath = Request.MapPath(Session["imgPath"].ToString());

                                if (db.SaveChanges() > 0)
                                {
                                    filename = Path.Combine(Server.MapPath("~/Content/img/users/"), filename);
                                    sa.UserImageFIle.SaveAs(filename);
                                    if (System.IO.File.Exists(oldImgPath))
                                    {
                                        System.IO.File.Delete(oldImgPath);
                                    }


                                    ViewBag.Message = "Data Updated";
                                    return(RedirectToAction("Profile"));
                                }
                            }
                            else
                            {
                                ViewBag.msg = "File Size must be Equal or less than 1mb";
                            }
                        }
                        else
                        {
                            ViewBag.msg = "Inavlid File Type";
                        }
                    }

                    //}
                    else
                    {
                        client.Image = Session["imgPath"].ToString();
                        if (l != null)
                        {
                            Session["ClientName"] = sa.UserName;
                            l.UserId          = userid;
                            l.Name            = sa.UserName;
                            l.Password        = sa.Password;
                            l.Email           = sa.Email;
                            l.RoleID          = 5;
                            db.Entry(l).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        client.UserName        = sa.UserName;
                        client.Email           = sa.Email;
                        client.Password        = sa.Password;
                        client.UserId          = userid;
                        db.Entry(client).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            ViewBag.Message = "Data Updated";
                            return(RedirectToAction("Profile"));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Updated";
                return(View());
            }
            return(View());
        }
        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);
            }
        }