예제 #1
0
        public ActionResult Index(StudentViewModel objStudentViewModel)
        {
            StudentMaster objStudentMaster = new StudentMaster()
            {
                Name       = objStudentViewModel.StudentName,
                ClassName  = objStudentViewModel.ClassName,
                ExamId     = objStudentViewModel.ExamId,
                RollNumber = objStudentViewModel.RollNumber
            };

            objStudentDBEntities.StudentMasters.Add(objStudentMaster);
            objStudentDBEntities.SaveChanges();

            foreach (var item in objStudentViewModel.ListOfStudentMarks)
            {
                StudentDetail objStudentDetail = new StudentDetail()
                {
                    MarksObtained = item.ObtainedMarks,
                    Percentage    = Convert.ToInt32(item.Percentage),  ///to check conversion
                    StudentId     = objStudentMaster.StudentId,
                    TotalMarks    = item.TotalMarks,
                    SubjectId     = item.SubjectId
                };
                objStudentDBEntities.StudentDetails.Add(objStudentDetail);
                objStudentDBEntities.SaveChanges();
            }


            return(Json(new { message = "Data successfully added", status = true }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Add new student to table
        /// </summary>
        /// <param name="student"></param>
        public void AddStudent(Student student)
        {
            do
            {
                //Generate student number before inserting
                student.StudentNumber = new StudentNumberGenerator().GenerateNumber();
            }
            //Validate that the generated student number does not exist in table
            while (!ValidateNonDuplicateNumber(student.StudentNumber, -1));

            db.Students.Add(student);

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                string validationErrors = "";

                foreach (var eve in e.EntityValidationErrors)
                {
                    validationErrors += String.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        validationErrors += String.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw new Exception(validationErrors);
            }
        }
        public IHttpActionResult PutStudent(int id, Student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != student.stu_id)
            {
                return(BadRequest());
            }

            db.Entry(student).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        // GET: StudentCourse

        public ActionResult Index(String Searching)
        {
            var model = DB.StudentCourses.AsQueryable();

            if (!String.IsNullOrEmpty(Searching))
            {
                model = model.Where(s => (s.Cours.Cname.Contains(Searching) ||
                                          s.Grade.Contains(Searching) ||
                                          s.Cours.Code.ToString().Contains(Searching) ||
                                          s.Student.Fname.Contains(Searching) ||
                                          s.Student.Lname.Contains(Searching) ||
                                          s.Student.Id.ToString().Contains(Searching)
                                          ));
            }

            foreach (var item in model)
            {
                if (item.Grade == null)
                {
                    item.Grade = "-";
                }
            }

            DB.SaveChanges();
            return(View("All", model));
        }
예제 #5
0
        public ActionResult Edit(Cours course)
        {
            var c = DB.Courses.Where(r => r.Code == course.Code).FirstOrDefault();

            c.Cname = course.Cname;
            DB.SaveChanges();
            return(RedirectToAction("All"));
        }
        public ActionResult Create([Bind(Include = "id,firstname,lastname,username,password")] user user)
        {
            if (ModelState.IsValid)
            {
                db.users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
예제 #7
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,BirthDate,MobileNo,Address")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
예제 #8
0
        public ActionResult AddStudentCourse(int stuId, int couId)
        {
            StudentCourse s = new StudentCourse();

            s.CourseId = couId;
            s.sid      = stuId;
            db.StudentCourses.Add(s);
            db.SaveChanges();
            CreateStudentData(stuId);
            return(PartialView("_StudentCourrse", db.Students.Find(stuId)));
        }
예제 #9
0
        public ActionResult Create(Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "id,batch1,year")] batch batch)
        {
            if (ModelState.IsValid)
            {
                db.batches.Add(batch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(batch));
        }
        public ActionResult Create([Bind(Include = "stdId,stdName,stdBranch,stdCity,stdPhn")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
예제 #12
0
        public ActionResult Create([Bind(Include = "StudentID,FirstName,LastName,Score")] StudentTable studentTable)
        {
            if (ModelState.IsValid)
            {
                db.StudentTables.Add(studentTable);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(studentTable));
        }
예제 #13
0
        public ActionResult Create([Bind(Include = "Id,BiSt,Predmet,Ocena")] Ispit ispit)
        {
            if (ModelState.IsValid)
            {
                db.Ispiti.Add(ispit);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ispit));
        }
        public ActionResult Create([Bind(Include = "id,course1,duration")] course course)
        {
            if (ModelState.IsValid)
            {
                db.courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
예제 #15
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Age,Class,Religion")] Table_Student table_Student)
        {
            if (ModelState.IsValid)
            {
                db.Table_Student.Add(table_Student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table_Student));
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "id,first_name,last_name,Password,email")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
예제 #17
0
        void InsertAndFindingError(string[] ListLine, StackPanel Stp)
        {
            var    thisUser             = DialogLogginViewModel.Users[0];
            var    DisciplineRegistered = ST.GetListDisciplineForThisUser(thisUser.ID).ToList();
            string speak = string.Empty;

            foreach (string Line in ListLine)
            {
                TextBlock Announcement = new TextBlock();
                Announcement.FontSize = 14;
                int    CheckDiscipline = 1;
                string ID   = Line.Substring(0, 5);
                var    data = ST.IsDateRegister().ToList()[0];
                foreach (GetListDisciplineForThisUser_Result Discipline in DisciplineRegistered)
                {
                    if (Discipline.DisciplineID != ID)
                    {
                        CheckDiscipline = 1;
                    }
                    else if (Discipline.DisciplineID == ID.Trim() && Discipline.DisciplineStatus == true)
                    {
                        CheckDiscipline         = 0;
                        Announcement.Foreground = new SolidColorBrush(Colors.Red);
                        Announcement.Text       = ID + " Discipline had registered";
                        break;
                    }
                    else if (Discipline.DisciplineID == ID.Trim() && Discipline.DisciplineStatus == false)
                    {
                        CheckDiscipline = 1;
                    }
                }
                if (CheckDiscipline == 1 && ID != " " && ID != "\n" && ID != null)
                {
                    try
                    {
                        ST.InsertRegisterStudyUnit(thisUser.ID, ID, data.SemesterID);
                        ST.SaveChanges();
                        Announcement.Foreground = new SolidColorBrush(Colors.Green);
                        Announcement.Text       = ID + " Successfully";
                    }
                    catch
                    {
                        Announcement.Foreground = new SolidColorBrush(Colors.Red);
                        Announcement.Text       = ID + " Discipline not open or does not exist. Please check back...";
                    }
                }
                speak += Announcement.Text + "...";
                warningAudio.SpeakAsync(speak);
                if (Announcement != null || Announcement.Text != " ")
                {
                    Stp.Children.Add(Announcement);
                }
            }
        }
예제 #18
0
        public ActionResult Edit(Student student)
        {
            var s = DB.Students.Where(r => r.Id == student.Id).FirstOrDefault();

            s.Id    = student.Id;
            s.Email = student.Email;
            s.Lname = student.Lname;
            s.Fname = student.Fname;
            s.Age   = student.Age;
            DB.SaveChanges();
            return(RedirectToAction("All"));
        }
        public ActionResult Create([Bind(Include = "id,firstname,lastname,nic,course_id,batch_id,telno")] resistration resistration)
        {
            if (ModelState.IsValid)
            {
                db.resistrations.Add(resistration);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.batch_id  = new SelectList(db.batches, "id", "batch1", resistration.batch_id);
            ViewBag.course_id = new SelectList(db.courses, "id", "course1", resistration.course_id);
            return(View(resistration));
        }
예제 #20
0
        public HttpResponseMessage UpdateStudentById(int id, [FromBody] Student student)
        {
            try
            {
                using (StudentDBEntities entities = new StudentDBEntities())
                {
                    var entity = entities.Students.FirstOrDefault(e => e.ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Student with id = " + id.ToString() + " not found"));
                    }
                    else
                    {
                        entity.FirstName    = student.FirstName;
                        entity.LastName     = student.LastName;
                        entity.Gender       = student.Gender;
                        entity.NoOfSubjects = student.NoOfSubjects;
                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
예제 #21
0
        public HttpResponseMessage Savestudent(tblStudent student)
        {
            int result = 0;

            try
            {
                DBcontext.tblStudents.Add(student);
                DBcontext.SaveChanges();
                result = 1;
            }
            catch (Exception e)
            {
                result = 0;
            }
            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
예제 #22
0
        public ActionResult Index(Cascade cas)
        {
            tblstud stud = new tblstud();

            if (ModelState.IsValid)
            {
                try
                {
                    stud.name    = cas.getstu.name;
                    stud.address = cas.getstu.address;
                    stud.gender  = cas.getstu.gender;
                    stud.stateid = cas.StateId;
                    stud.cityid  = cas.CityId;
                    cas.getstu   = stud;
                    sd.tblstuds.Add(stud);
                    sd.SaveChanges();
                    State_Bind();
                }
                catch
                {
                    State_Bind();
                    return(View(cas));
                }
            }

            return(View(cas));
        }
예제 #23
0
        public HttpResponseMessage SaveStudent(StudentTable astudent)
        {
            int result = 0;

            try
            {
                dbContext.StudentTables.Add(astudent);
                dbContext.SaveChanges();
                result = 1;
            }
            catch (Exception e)
            {
                result = 0;
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
예제 #24
0
        private void OnConfirmChangePictureCommand(object obj)
        {
            if (ProfilePictureSource == null && PicturePath == null)
            {
                warningAudio.SpeakAsync("You have not selected a picture yet. Click browse to select one..");
                return;
            }

            UserImage data        = new UserImage();
            var       ImagePath   = PicturePath;
            var       ImageToByte = File.ReadAllBytes(PicturePath);

            ST.AddNewUserImage(ImagePath, ImageToByte, Students[0].StudentID);
            ST.SaveChanges();

            warningAudio.SpeakAsync("Change successfully..");
        }
        public ActionResult DeleteContact(string id)
        {
            var            db     = new StudentDBEntities();
            List <Contact> dbInfo = db.Contact.ToList();

            db.Contact.Remove(dbInfo[int.Parse(id)]);
            db.SaveChanges();
            return(RedirectToAction("Contact"));
        }
 public IHttpActionResult Add([FromBody] StudentCourseDTO sc)
 {
     try
     {
         if (sc != null)
         {
             DB.StudentCourses.Add(new StudentCourse {
                 CourseCode = sc.CourseCode, StudentId = sc.StudentId, Grade = sc.Grade
             });
             DB.SaveChanges();
         }
         return(Ok(true));
     }
     catch (Exception e)
     {
         return(Ok(new { StatusCode = 200, e }));
     }
 }
예제 #27
0
 public IHttpActionResult Add([FromBody] StudentDTO student)
 {
     try
     {
         if (student != null)
         {
             DB.Students.Add(new Student {
                 Id = student.Id, Email = student.Email, Fname = student.Fname, Lname = student.Lname, Age = student.Age
             });
             DB.SaveChanges();
         }
         return(Ok(true));
     }
     catch (Exception e)
     {
         return(Ok(new { StatusCode = 200, e }));
     }
 }
        public ActionResult DeleteMember(string id)
        {
            var           db     = new StudentDBEntities();
            List <Member> dbInfo = db.Member.ToList();

            db.Member.Remove(dbInfo[int.Parse(id)]);
            db.SaveChanges();
            return(RedirectToAction("MemberList"));
        }
예제 #29
0
        public ActionResult ChangeRunningMessage(ContactList NewMessage)
        {
            var db = new StudentDBEntities();
            List <RunningMessage> RunMessage = db.RunningMessage.ToList();

            RunMessage[0].Message = NewMessage.RunningMessage;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public IHttpActionResult Add([FromBody] CourseDTO course)
 {
     try
     {
         if (course != null)
         {
             DB.Courses.Add(new Cours {
                 Code = course.Code, Cname = course.Cname
             });
             DB.SaveChanges();
         }
         return(Ok(true));
     }
     catch (Exception e)
     {
         return(Ok(new { StatusCode = 200, e }));
     }
 }