Example #1
0
        public JsonResult GetStudentbyYear(int?facultyid)
        {
            AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();
            var tblYearBatch = _db.tblYearBatches.ToList();
            Dictionary <string, int> data = new Dictionary <string, int>();

            foreach (var items in tblYearBatch)
            {
                var total = 0;
                if (facultyid != null)
                {
                    total = _db.tblStudents.Where(s => s.YearBatchId == items.YearBatchId && s.Faculty_Id == facultyid).Count();
                }
                else
                {
                    total = _db.tblStudents.Where(s => s.YearBatchId == items.YearBatchId).Count();
                }
                data.Add(items.Year_Batch, total);
            }
            return(new JsonResult
            {
                Data = data,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #2
0
        //List Student Submitted Assignment By StudentId
        //public List<TeacherViewModel> GetTeacherByTeacherName(string search)
        //{
        //    return teaDB.SearchTeacherByName(search);
        //}
        //public HttpResponseMessage GetTeacherByTeacherName(string name)
        //{
        //    AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();
        //    var teacher = _db.tblTeachers.Where(t => t.Name == name).ToList();
        //    string message = "No Data Found";
        //    if (teacher == null)
        //    {
        //        return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
        //    }
        //    else
        //    {
        //        return Request.CreateResponse(HttpStatusCode.OK, teacher);
        //    }

        //}
        public HttpResponseMessage Post([Bind(Include = "Email,Model")] TeacherViewModel tvm)
        {
            AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities();
            string message  = "Teacher Added Successfully";
            bool   isexists = teaDB.EmailExists(tvm.Email);

            if (isexists)
            {
                ModelState.AddModelError("Email", "Email Already Exist");
            }
            if (ModelState.IsValid)
            {
                teaDB.Add(tvm);


                //tblTeacher tb = db.tblTeachers.Where(x => x.Email == tvm.Email).FirstOrDefault();
                //if (tb != null)
                //{
                //    teaDB.SendEmail(tb.Teacher_Id);
                //}
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        public HttpResponseMessage GetFile(int routineid)
        {
            //Create HTTP Response.
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            //Fetch the File data from Database.
            //FilesEntities entities = new FilesEntities();
            AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();

            tblAssignmentRoutine file = _db.tblAssignmentRoutines.Where(r => r.Routine_Id == routineid).FirstOrDefault();

            //Set the Response Content.
            response.Content = new ByteArrayContent(file.Data);

            //Set the Response Content Length.
            response.Content.Headers.ContentLength = file.Data.LongLength;

            //Set the Content Disposition Header Value and FileName.
            response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = file.Name;
            //var filename = file.Name;

            //Set the File Content Type.
            response.Content.Headers.ContentType = new MediaTypeHeaderValue(file.Content_Type);
            // return Request.CreateResponse(HttpStatusCode.OK, filename);
            return(response);
        }
        public HttpResponseMessage Post([Bind(Include = "Email,Model")] StudentViewModel svm)
        {
            AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities();
            string message  = "Student Added Successfully";
            bool   isexists = stuDB.EmailExists(svm.Email);

            if (isexists)
            {
                ModelState.AddModelError("Email", "Email Already Exist");
            }
            if (ModelState.IsValid)
            {
                //    stuDB.Add(svm);
                //stuDB.SendSMS();

                tblStudent tb = db.tblStudents.Where(x => x.Email == svm.Email).FirstOrDefault();
                if (tb != null)
                {
                    stuDB.SendEMail(tb.Student_Id);
                }

                //tblStudent tb1 = db.tblStudents.Where(x => x.Phone == svm.Phone).FirstOrDefault();
                //if (tb1 != null)
                //{
                //    stuDB.SendSMS(tb1.Phone);
                //}

                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        public JsonResult GetYearBatchList(string sortColumnName = "Year_Batch", string sortOrder = "asc", int pageSize = 3, int currentPage = 1, string searchText = "")
        {
            List <YearBatchViewModel> List = new List <YearBatchViewModel>();
            int totalPage   = 0;
            int totalRecord = 0;


            using (AssignmentManagementSystemEntities dc = new AssignmentManagementSystemEntities())
            {
                dc.Configuration.ProxyCreationEnabled = false;
                var emp = yearDB.ListAll().Select(a => a);
                //Search
                if (!string.IsNullOrEmpty(searchText))
                {
                    emp = emp.Where(x => x.Year_Batch.Contains(searchText));
                }
                totalRecord = emp.Count();
                if (pageSize > 0)
                {
                    totalPage = totalRecord / pageSize + ((totalRecord % pageSize) > 0 ? 1 : 0);
                    List      = emp.OrderBy(sortColumnName + " " + sortOrder).Skip(pageSize * (currentPage - 1)).Take(pageSize).ToList();
                }
                else
                {
                    List = emp.ToList();
                }
            }

            return(new JsonResult
            {
                //Data = new { List = List, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage},
                Data = new { List = List, totalRecord = totalRecord, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage, pageSize = pageSize },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public HttpResponseMessage GetFile(int fileId)
        {
            //Create HTTP Response.
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            //Fetch the File data from Database.
            //FilesEntities entities = new FilesEntities();
            AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();

            tblfile file = _db.tblfiles.ToList().Find(p => p.id == fileId);

            //Set the Response Content.
            response.Content = new ByteArrayContent(file.Data);

            //Set the Response Content Length.
            response.Content.Headers.ContentLength = file.Data.LongLength;

            //Set the Content Disposition Header Value and FileName.
            //response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
            //response.Content.Headers.ContentDisposition.FileName = file.Name;
            response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("inline");


            //Set the File Content Type.
            response.Content.Headers.ContentType = new MediaTypeHeaderValue(file.ContentType);
            // response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/msword");
            //response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("images/jpeg");
            //response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");

            return(response);
        }
        public HttpResponseMessage GetFiles()
        {
            //FilesEntities entities = new FilesEntities();
            AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();

            var files = from file in _db.tblfiles
                        select new { id = file.id, Name = file.Name };

            return(Request.CreateResponse(HttpStatusCode.OK, files));
        }
        public JsonResult GetStudentSubmittedAssignmentList(string sortColumnName = "Routine_Id", string sortOrder = "asc", int pageSize = 3, int currentPage = 1, string searchText = "", int?routineid = 0)
        {
            List <SubmittedAssignmentViewModel> List = new List <SubmittedAssignmentViewModel>();
            int totalPage   = 0;
            int totalRecord = 0;

            using (AssignmentManagementSystemEntities dc = new AssignmentManagementSystemEntities())
            {
                dc.Configuration.ProxyCreationEnabled = false;
                var emp = subDB.ListAll().Select(a => a);
                // var emp = subDB.ListAll().Where(e => e.Routine_Id == routineid);
                if (routineid == null)
                {
                    emp = subDB.ListAll().Select(a => a);
                }
                else
                {
                    emp = subDB.ListAll().Select(a => a).Where(e => e.Routine_Id == routineid);
                }



                //Search
                if (!string.IsNullOrEmpty(searchText))
                {
                    emp = emp.Where(a => a.Assignment_Name.Contains(searchText) || a.TeacherName.Contains(searchText) || a.StudentName.Contains(searchText) || a.FacultyName.Contains(searchText) || a.SectionName.Contains(searchText) || a.SemesterName.Contains(searchText) || a.YearBatch.Contains(searchText) || a.Submitted_Date.ToString().Contains(searchText) || a.Checked_Status.ToString().Contains(searchText) || a.Feedback_Status.ToString().Contains(searchText) || a.Marking.ToString().Contains(searchText));
                }
                totalRecord = emp.Count();
                if (pageSize > 0)
                {
                    totalPage = totalRecord / pageSize + ((totalRecord % pageSize) > 0 ? 1 : 0);
                    List      = emp.OrderBy(sortColumnName + " " + sortOrder).Skip(pageSize * (currentPage - 1)).Take(pageSize).ToList();
                }
                else
                {
                    List = emp.ToList();
                }
            }

            return(new JsonResult
            {
                //Data = new { List = List, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage},
                Data = new { List = List, totalRecord = totalRecord, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage, pageSize = pageSize },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public HttpResponseMessage Post([Bind(Include = "Email,Model")] ForgetPasswordViewModel fpvm)
        {
            AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities();
            string message  = "Your Password is Sent to Email";
            bool   isexists = fpDB.EmailExists(fpvm.Email);

            if (!isexists)
            {
                ModelState.AddModelError("Email", "Not Registered Email");
            }
            if (ModelState.IsValid)
            {
                fpDB.SendRecoveryPasswordEMail(fpvm);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        public JsonResult GetStudentList(string sortColumnName = "Name", string sortOrder = "asc", int pageSize = 3, int currentPage = 1, string searchText = "")
        {
            List <StudentViewModel> List = new List <StudentViewModel>();
            int totalPage   = 0;
            int totalRecord = 0;


            using (AssignmentManagementSystemEntities dc = new AssignmentManagementSystemEntities())
            {
                dc.Configuration.ProxyCreationEnabled = false;
                //var emp = dc.tblStudents.Select(a => a);
                var emp = stuDB.ListAll().Select(a => a);

                //var emp = stuDB.ListAll().Select(x => new { Id = x.Student_Id, Name = x.Name, Email = x.Email, Gender = x.Gender, Phone = x.Phone ,Address=x.Address, YearBatchId=x.YearBatchId, YearBatch=x.tblYearBatch.YearBatchId, FacultyId=x.Faculty_Id, FacultyName=x.tblFaculty.Faculty_Name, SectionId=x.Section_Id, SectionName=x.tblSection.Sec_Name, SemesterId=x.Semester_Id, SemesterName=x.tblSemester.Semester_Name});

                //Search
                if (!string.IsNullOrEmpty(searchText))
                {
                    emp = emp.Where(x => x.Name.Contains(searchText) || x.Email.Contains(searchText) || x.Gender.Contains(searchText) || x.Phone.Contains(searchText) || x.Address.Contains(searchText) || x.Year_Batch.Contains(searchText) || x.Faculty_Name.Contains(searchText) || x.Sec_Name.Contains(searchText) || x.Semester_Name.Contains(searchText));
                }
                totalRecord = emp.Count();
                if (pageSize > 0)
                {
                    totalPage = totalRecord / pageSize + ((totalRecord % pageSize) > 0 ? 1 : 0);
                    List      = emp.OrderBy(sortColumnName + " " + sortOrder).Skip(pageSize * (currentPage - 1)).Take(pageSize).ToList();
                }
                else
                {
                    List = emp.ToList();
                }
            }

            return(new JsonResult
            {
                //Data = new { List = List, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage},
                Data = new { List = List, totalRecord = totalRecord, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage, pageSize = pageSize },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #11
0
        public HttpResponseMessage Put([Bind(Include = "Faculty_Name,Model")] FacultyViewModel fvm)
        {
            AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities();
            var        faculty  = facDB.ListAll().Find(f => f.Id.Equals(fvm.Id));
            string     message  = "Faculty Updated Successfully";
            tblFaculty tb       = db.tblFaculties.Where(s => s.Faculty_Id == fvm.Id).FirstOrDefault();
            bool       isexists = facDB.CheckFacultyNameExist(fvm.Faculty_Name);

            if (isexists)
            {
                if (tb.Faculty_Name == fvm.Faculty_Name)
                {
                    if (ModelState.IsValid)
                    {
                        facDB.Update(fvm);
                        return(Request.CreateResponse(HttpStatusCode.OK, message));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                    }
                }
                else
                {
                    ModelState.AddModelError("Faculty_Name", "Faculty Name Already Exist");
                }
            }

            if (ModelState.IsValid)
            {
                facDB.Update(fvm);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        public HttpResponseMessage Put([Bind(Include = "Routine_Id,Model")] SubmittedAssignmentViewModel sub)
        {
            AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();
            string message = "Assignment Updated Successfully";

            if (ModelState.IsValid)
            {
                bool isexists = subDB.StudentAssignmentMatch(sub.Student_Id, sub.Routine_Id);
                if (!isexists)
                {
                    ModelState.AddModelError("Routine_Id", "This Assignment is not Assigned to selected Student");
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
                else
                {
                    tblSubmittedAssignment tb = _db.tblSubmittedAssignments.Where(a => a.ID == sub.Id).FirstOrDefault();
                    if (tb.Assignmnet_Location == 1 && sub.Assignmnet_Location == 2)
                    {
                        ModelState.AddModelError("Routine_Id", "This Assignment can not be directly handover to student from teacher Location");
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                    }
                    else if (tb.Assignmnet_Location == 2 && sub.Assignmnet_Location == 1)
                    {
                        ModelState.AddModelError("Routine_Id", "The Assignment can not be directly handover to Teacher  from Student Location");
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                    }
                    else
                    {
                        subDB.Update(sub);
                        return(Request.CreateResponse(HttpStatusCode.OK, message));
                    }
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        public HttpResponseMessage Put([Bind(Include = "Year_Batch,Model")] YearBatchViewModel yvm)
        {
            AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities();
            var          year     = yearDB.ListAll().Find(y => y.Id.Equals(yvm.Id));
            string       message  = "Year/Batch Updated Successfully";
            tblYearBatch tb       = db.tblYearBatches.Where(y => y.YearBatchId == yvm.Id).FirstOrDefault();
            bool         isexists = yearDB.CheckYearbatch(yvm.Year_Batch);

            if (isexists)
            {
                if (tb.Year_Batch == yvm.Year_Batch)
                {
                    if (ModelState.IsValid)
                    {
                        yearDB.Update(yvm);
                        return(Request.CreateResponse(HttpStatusCode.OK, message));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                    }
                }
                else
                {
                    ModelState.AddModelError("Year_Batch", "Year/Batch Already Exist");
                }
            }

            if (ModelState.IsValid)
            {
                yearDB.Update(yvm);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Example #14
0
        public HttpResponseMessage Put([Bind(Include = "Email,Model")] TeacherViewModel tvm)
        {
            AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities();
            var        student  = teaDB.ListAll().Find(t => t.Id.Equals(tvm.Id));
            string     message  = "Teacher Updated Successfully";
            tblTeacher tb       = db.tblTeachers.Where(t => t.Teacher_Id == tvm.Id).FirstOrDefault();
            bool       isexists = teaDB.EmailExists(tvm.Email);

            if (isexists)
            {
                if (tb.Email == tvm.Email)
                {
                    if (ModelState.IsValid)
                    {
                        teaDB.Update(tvm);
                        return(Request.CreateResponse(HttpStatusCode.OK, message));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                    }
                }
                else
                {
                    ModelState.AddModelError("Email", "Email Already Exist");
                }
            }

            if (ModelState.IsValid)
            {
                teaDB.Update(tvm);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        public HttpResponseMessage Put([Bind(Include = "Sec_Name,Model")] SectionViewModel svm)
        {
            AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities();
            var        section  = secDB.ListAll().Find(s => s.Id.Equals(svm.Id));
            string     message  = "Section Updated Successfully";
            tblSection tb       = db.tblSections.Where(s => s.Section_Id == svm.Id).FirstOrDefault();
            bool       isexists = secDB.CheckSectionNameExist(svm.Sec_Name);

            if (isexists)
            {
                if (tb.Sec_Name == svm.Sec_Name)
                {
                    if (ModelState.IsValid)
                    {
                        secDB.Update(svm);
                        return(Request.CreateResponse(HttpStatusCode.OK, message));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                    }
                }
                else
                {
                    ModelState.AddModelError("Sec_Name", "Section Name Already Exist");
                }
            }

            if (ModelState.IsValid)
            {
                secDB.Update(svm);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
        public HttpResponseMessage SaveFile()
        {
            //Create HTTP Response.
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            //Check if Request contains File.
            if (HttpContext.Current.Request.Files.Count == 0)
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            //Read the File data from Request.Form collection.
            HttpPostedFile postedFile = HttpContext.Current.Request.Files[0];

            //Convert the File data to Byte Array.
            byte[] bytes;
            using (BinaryReader br = new BinaryReader(postedFile.InputStream))
            {
                bytes = br.ReadBytes(postedFile.ContentLength);
            }

            //Insert the File to Database Table.
            AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();

            tblfile file = new tblfile
            {
                Name        = Path.GetFileName(postedFile.FileName),
                ContentType = postedFile.ContentType,
                Data        = bytes
            };

            _db.tblfiles.Add(file);
            _db.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK, new { id = file.id, Name = file.Name }));
        }
        public HttpResponseMessage Post()
        {
            var message                 = "Routine Added Successfully";
            var Assignment_Name         = HttpContext.Current.Request.Params["Assignment_Name"];
            var Teacher_Id              = HttpContext.Current.Request.Params["Teacher_Id"];
            var Assignment_Release_Date = HttpContext.Current.Request.Params["Assignment_Release_Date"];
            var Deadline                = HttpContext.Current.Request.Params["Deadline"];
            var Section_Id              = HttpContext.Current.Request.Params["Section_Id"];
            var Faculty_Id              = HttpContext.Current.Request.Params["Faculty_Id"];
            var Semester_Id             = HttpContext.Current.Request.Params["Semester_Id"];
            var Year_Batch_Id           = HttpContext.Current.Request.Params["Year_Batch_Id"];

            //var file= HttpContext.Current.Request.Files[0];
            if (Assignment_Name == "")
            {
                ModelState.AddModelError("Assignment_Name", "Enter Assignment Name");
            }
            if (Teacher_Id == "")
            {
                ModelState.AddModelError("Teacher_Name", "Select Subject Teacher");
            }
            if (Assignment_Release_Date == "")
            {
                ModelState.AddModelError("Assignment_Release_Date", "Select Release Date");
            }
            if (Deadline == "")
            {
                ModelState.AddModelError("Deadline", "Select Assignmnet Deadline");
            }
            if (Section_Id == "")
            {
                ModelState.AddModelError("Section_Name", "Select Section");
            }
            if (Faculty_Id == "")
            {
                ModelState.AddModelError("Faculty_Name", "Select Faculty");
            }
            if (Semester_Id == "")
            {
                ModelState.AddModelError("Semester_Name", "Select Semester");
            }
            if (Year_Batch_Id == "")
            {
                ModelState.AddModelError("Year_Batch", "Select Year Batch");
            }
            if (HttpContext.Current.Request.Files.Count == 0)
            {
                ModelState.AddModelError("PDF", "Choose File");
            }
            if (ModelState.IsValid)
            {
                //Read the File data from Request.Form collection.
                HttpPostedFile postedFile = HttpContext.Current.Request.Files[0];
                //Convert the File data to Byte Array.
                byte[] bytes;
                using (BinaryReader br = new BinaryReader(postedFile.InputStream))
                {
                    bytes = br.ReadBytes(postedFile.ContentLength);
                }

                //Insert the File to Database Table.
                AssignmentManagementSystemEntities _db = new AssignmentManagementSystemEntities();

                tblAssignmentRoutine tb = new tblAssignmentRoutine();
                tb.Assignment_Name         = Assignment_Name;
                tb.Teacher_Id              = Convert.ToInt32(Teacher_Id);
                tb.Assignment_Release_Date = Convert.ToDateTime(Assignment_Release_Date);
                tb.Deadline     = Convert.ToDateTime(Deadline);
                tb.Section_Id   = Convert.ToInt32(Section_Id);
                tb.Faculty_Id   = Convert.ToInt32(Faculty_Id);
                tb.Semester_Id  = Convert.ToInt32(Semester_Id);
                tb.YearBatchId  = Convert.ToInt32(Year_Batch_Id);
                tb.Name         = Path.GetFileName(postedFile.FileName);
                tb.Content_Type = postedFile.ContentType;
                tb.Data         = bytes;

                _db.tblAssignmentRoutines.Add(tb);
                _db.SaveChanges();

                tblStudentRoutineRelation tsr = new tblStudentRoutineRelation();
                var studnet = _db.tblStudents.Where(s => s.Faculty_Id == tb.Faculty_Id && s.Section_Id == tb.Section_Id && s.Semester_Id == tb.Semester_Id && s.YearBatchId == tb.YearBatchId).ToList();
                foreach (var item in studnet)
                {
                    tsr.RoutineId = tb.Routine_Id;
                    tsr.StudentId = item.Student_Id;
                    _db.tblStudentRoutineRelations.Add(tsr);
                    _db.SaveChanges();
                }
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }