Beispiel #1
0
        public List <Semesters> GetSemeSubConfigData()
        {
            List <Semesters>    lstSemSubConfigData        = new List <Semesters>();
            Semesters           objSemester                = null;
            dataAccessWorkplace objobjdataAccessWorkplace3 = new dataAccessWorkplace();
            DataTable           dt = new DataTable();

            dt = objobjdataAccessWorkplace3.getSemSubConfig();
            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    objSemester                         = new Semesters();
                    objSemester.objSubjects             = new Subjects();
                    objSemester.SemSubConfigID          = (int)dr["SemSubConfigID"];
                    objSemester.SemesterID              = (int)dr["SemesterID"];
                    objSemester.SemesterCode            = dr["SemesterCode"].ToString();
                    objSemester.SemesterName            = dr["SemesterName"].ToString();
                    objSemester.objSubjects.SubjectID   = Convert.ToInt32(dr["SubjectID"].ToString());
                    objSemester.objSubjects.SubjectCode = dr["SubjectCode"].ToString();
                    //objSemester.objSubjects.SubjectName = dr["SubjectName"].ToString();
                    lstSemSubConfigData.Add(objSemester);
                }
            }
            return(lstSemSubConfigData);
        }
Beispiel #2
0
        public async Task <IActionResult> PutSemesters(int id, Semesters semesters)
        {
            if (id != semesters.SemesterId)
            {
                return(BadRequest());
            }

            _context.Entry(semesters).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SemestersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
 public List <StudentModel> GetStudentBySemesterId(int semesterId)
 {
     using (SZPNUWContext context = new SZPNUWContext())
     {
         List <Students>     students = context.Studentsemester.Where(x => x.Semesterid == semesterId).Select(x => x.Student).Include(x => x.User).ToList();
         Semesters           semester = context.Semesters.FirstOrDefault(x => x.Id == semesterId);
         List <StudentModel> model    = new List <StudentModel>();
         students.ForEach(x => model.Add(new StudentModel
         {
             Id          = x.Id,
             Login       = x.User.Login,
             FirstName   = x.User.Firstname,
             LastName    = x.User.Lastname,
             PESEL       = x.User.Pesel,
             Address     = x.User.Address,
             City        = x.User.City,
             AlbumNumber = x.Albumnumber,
             DateOfBirth = x.User.Dateofbirth,
             UserId      = x.Userid,
             UserType    = (UserTypes)x.User.Usertype,
             Semester    = new SemesterModel {
                 Id = semester.Id, Department = semester.Fieldofstudy, SemesterNumber = semester.Semesternumber, Year = semester.Academicyear
             }
         }));
         return(model);
     }
 }
Beispiel #4
0
 public StudentModel GetStudentById(int id)
 {
     using (SZPNUWContext context = new SZPNUWContext())
     {
         Students student = context.Students.Include(x => x.User).FirstOrDefault(s => s.Id == id);
         if (student == null)
         {
             return(null);
         }
         Semesters    semester = context.Studentsemester.Include(x => x.Semester).Where(x => x.Studentid == id).OrderBy(x => x.Semester.Semesternumber).Last().Semester;
         StudentModel model    = new StudentModel
         {
             Id          = student.Id,
             Login       = student.User.Login,
             FirstName   = student.User.Firstname,
             LastName    = student.User.Lastname,
             PESEL       = student.User.Pesel,
             Address     = student.User.Address,
             City        = student.User.City,
             AlbumNumber = student.Albumnumber,
             DateOfBirth = student.User.Dateofbirth,
             UserId      = student.Userid,
             UserType    = (UserTypes)student.User.Usertype,
             Semester    = new SemesterModel {
                 Id = semester.Id, Department = semester.Fieldofstudy, SemesterNumber = semester.Semesternumber, Year = semester.Academicyear
             }
         };
         return(model);
     }
 }
        public void CreateStemesterExistTest()
        {
            Semesters s  = createUniqueSemester();
            Semesters s2 = g.createSemester(s.Name);

            Assert.IsNull(s2, "Semestr nie zostal stworzony");
        }
Beispiel #6
0
        public ActionResult Create(CreateOrEditCourseViewModel createViewModel)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();

                var createModel = ConvertToDomainModel(createViewModel);

                createModel.StudentId = Guid.Parse(userId);

                var domainIModel = Courses.CreateCourse(createModel);
                var domainModel  = new CourseDomainModel();

                if (domainIModel.GetType() == typeof(ErrorDomainModel))
                {
                    var semesterModels = Semesters.GetAllSemesters();

                    if (semesterModels.Count > 0 && semesterModels.First().GetType() == typeof(ErrorDomainModel))
                    {
                        return(GradeTrackerError(semesterModels.First(), null));
                    }

                    createViewModel.Semesters   = GetSemestersForDropDown(semesterModels);
                    createViewModel.YearOptions = GetYearDropDownOptions();

                    return(GradeTrackerError(domainIModel, createViewModel));
                }
                else
                {
                    domainModel = (CourseDomainModel)domainIModel;
                }

                var newCourseViewModel = new CourseViewModel(domainModel);

                var semesterModel = Semesters.GetSemester(domainModel.SemesterId);

                if (semesterModel.GetType() == typeof(ErrorDomainModel))
                {
                    return(GradeTrackerError(semesterModel, null));
                }

                newCourseViewModel.Semester = GetSemesterViewModel(semesterModel);

                return(View("ViewCourse", newCourseViewModel));
            }
            else
            {
                var semesterModels = Semesters.GetAllSemesters();

                if (semesterModels.Count > 0 && semesterModels.First().GetType() == typeof(ErrorDomainModel))
                {
                    return(GradeTrackerError(semesterModels.First(), null));
                }

                createViewModel.Semesters   = GetSemestersForDropDown(semesterModels);
                createViewModel.YearOptions = GetYearDropDownOptions();

                return(View("Add", createViewModel));
            }
        }
Beispiel #7
0
        public ActionResult UpdateCourse(CreateOrEditCourseViewModel updatedCourse)
        {
            if (ModelState.IsValid)
            {
                var domainModel = ConvertToDomainModel(updatedCourse);

                var updatedModel = Courses.UpdateCourse(domainModel);

                if (ReferenceEquals(updatedModel.GetType(), typeof(ErrorDomainModel)))
                {
                    return(GradeTrackerError(updatedModel, updatedCourse));
                }
                else
                {
                    var castedDomainModel = (CourseDomainModel)updatedModel;
                    var viewModel         = new CourseViewModel((CourseDomainModel)updatedModel);
                    var semesterViewModel = Semesters.GetSemester(castedDomainModel.SemesterId);
                    viewModel.Semester = GetSemesterViewModel(semesterViewModel);

                    return(View("CourseUpdated", viewModel));
                }
            }
            else
            {
                return(View("UpdateCourse", updatedCourse));
            }
        }
Beispiel #8
0
        public async Task <ActionResult <Semesters> > PostSemesters(Semesters semesters)
        {
            _context.Semesters.Add(semesters);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSemesters", new { id = semesters.SemesterId }, semesters));
        }
Beispiel #9
0
        public bool AddRealisation(string ver, int semestrID, int subjectID, int?userID)
        {
            Random rand = new Random();
            int    id   = rand.Next(899999) + 100000;

            using (var db = new StorageContext())
            {
                Semesters semestr = db.Semesters.Find(semestrID);
                Subjects  subject = db.Subjects.Find(subjectID);
                Users     user    = null;
                if (userID.HasValue)
                {
                    user = db.Users.Find(userID.Value);
                }
                Realisations realisation = new Realisations()
                {
                    RealisationID = id,
                    Semesters     = semestr,
                    Subjects      = subject,
                    Users         = user,
                    Ver           = ver
                };
                db.Realisations.Add(realisation);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception)
                {
                    return(false);
                }
                return(true);
            }
        }
Beispiel #10
0
        public ActionResult semester(Semesters s)
        {
            connection();


            if (s.Semestername == "" || s.Semestername == null)
            {
                return(View());
            }
            else
            {
                string query = "Select Semesterid from Semesters where Semesterid='" + s.Semesterid + "'";
                cmd = new SqlCommand(query, con);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    dr.Close();
                    ViewBag.Message = "Semester already exist";
                }
                else
                {
                    dr.Close();
                    string str = "insert into Semesters(Semestername) values('" + s.Semestername + "')";
                    cmd = new SqlCommand(str, con);
                    cmd.ExecuteNonQuery();
                    ViewBag.Message = "Semester Added Successfully";
                }
                return(View(s));
            }
        }
Beispiel #11
0
 internal void Remove(ViewItemSemester viewItemSemester)
 {
     if (Semesters != null)
     {
         Semesters.Remove(viewItemSemester);
     }
 }
Beispiel #12
0
        public void passSemesterDetailsDelete(Semesters objSemesters)
        {
            //passing the values as object to the dataAccessLayer to store in b
            dataAccessWorkplace objdataAccessWorkplaceUpdate = new dataAccessWorkplace();

            objdataAccessWorkplaceUpdate.deleteSemesterDetails(objSemesters);
        }
Beispiel #13
0
        public void insertSemesters(Semesters objSemesters)
        {
            //passing the values as object to the dataAccessLayer to store in b
            dataAccessWorkplace objdataAccessWorkplace3 = new dataAccessWorkplace();

            objdataAccessWorkplace3.SemesterDataInToDb(objSemesters);
        }
        //method which get user enterd data.
        private Semesters getSemstersDtl()
        {
            Semesters objSemesters = new Semesters();

            objSemesters.SemesterCode = txtSemCode.Text.ToString();
            objSemesters.SemesterName = txtSemName.Text.ToString();
            return(objSemesters);
        }
Beispiel #15
0
        public IActionResult DeleteSemester(int id)
        {
            Semesters semester = _db.Semesters.Find(id);

            _db.Semesters.Remove(semester);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            Semesters semesters = db.Semesters.Find(id);

            db.Semesters.Remove(semesters);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //method which fills the grid with user entered data.
        public void fillToGrid()
        {
            List <Semesters> alreadyGridList = (List <Semesters>)dgvSemDetails.DataSource;
            Semesters        objSemesters    = getSemstersDtl();

            alreadyGridList.Add(objSemesters);
            dgvSemDetails.DataSource = null;
            dgvSemDetails.DataSource = alreadyGridList;
        }
Beispiel #18
0
        public DataTable ViewSemestersData()
        {
            List <Semesters>    lstSemesters = new List <Semesters>();
            Semesters           objSemesters = null;
            dataAccessWorkplace objobjdataAccessWorkplace4 = new dataAccessWorkplace();
            DataTable           dt = new DataTable();

            dt = objobjdataAccessWorkplace4.getSemestertData();
            return(dt);;
        }
Beispiel #19
0
 public ActionResult Edit([Bind(Include = "SemesterID,Semester")] Semesters semesters)
 {
     if (ModelState.IsValid)
     {
         db.Entry(semesters).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SemesterID = new SelectList(db.SemesterYear, "SemesterYearID", "SemesterYearID", semesters.SemesterID);
     return(View(semesters));
 }
        private void Add()
        {
            int number = Semesters.Count > 0 ? Semesters.Last().Number + 1 : 1;
            var sem    = new Semester {
                Number = number
            };

            Semesters.Add(sem);
            SelectedSemester = sem;
            RaisePropertyChanged("Semesters");
        }
Beispiel #21
0
        public ActionResult Create([Bind(Include = "SemesterID,Semester")] Semesters semesters)
        {
            if (ModelState.IsValid)
            {
                db.Semesters.Add(semesters);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SemesterID = new SelectList(db.SemesterYear, "SemesterYearID", "SemesterYearID", semesters.SemesterID);
            return(View(semesters));
        }
 private Semesters createUniqueSemester()
 {
     while (true)
     {
         Semesters s = g.createSemester(uniqueIndexGenerator());
         if (s != null)
         {
             semesters.Add(s);
             return(s);
         }
     }
 }
Beispiel #23
0
        public IActionResult EditSemester(Semesters semester)
        {
            Semesters updateSemester = _db.Semesters.SingleOrDefault(i => i.SemesterId == semester.SemesterId);

            if (updateSemester != null)
            {
                updateSemester.Name = semester.Name;
                _db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public void getSemesterDetails()
        {
            Semesters objSemesters = new Semesters();

            objSemesters.SemesterName = txtSemName.Text;
            objSemesters.SemesterCode = txtSemCode.Text;

            //passing above values as a object to the business layer.
            systemManager objsystemManager = new systemManager();

            objsystemManager.insertSemesters(objSemesters);
        }
 /*
  * Semester
  *
  */
 public Semesters GetSemesterByName(string semesterName)
 {
     using (var db = new ScheduleKSTUContext())
     {
         Semesters semester = db.Semesters.FirstOrDefault(sem => sem.Name == semesterName);
         return(new Semesters
         {
             Id = semester.Id,
             Name = semester.Name
         });
     }
 }
        private async Task LoadData(bool isNew = false)
        {
            using (UserDialogs.Instance.Loading())
            {
                Semesters = await SystemApi.UsersClient.UsersGetSemestersAndMyCoursesGetAsync();

                if (!isNew)
                {
                    SelectedSemester = Semesters.First(x => x.Courses != null && x.Courses.Any(c => c.Id == Survey.CourseId));
                    SelectedCourse   = Semesters.SelectMany(x => x.Courses).First(x => x.Id == Survey.CourseId);
                }
            }
        }
Beispiel #27
0
        // GET: Semesters/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Semesters semesters = db.Semesters.Find(id);

            if (semesters == null)
            {
                return(HttpNotFound());
            }
            return(View(semesters));
        }
Beispiel #28
0
        public int StartSemesterCalculator()
        {
            int           ret              = 0;
            int           smallestYear     = int.MaxValue;
            int           smallestSemester = int.MaxValue;
            List <String> semesters        = new List <string>();
            Semesters     semester         = new Semesters();

            foreach (var item in this.StudentClasses)
            {
                if (item.year != null)
                {
                    if (int.Parse(item.year) < smallestYear)
                    {
                        smallestYear = int.Parse(item.year);
                    }
                }
            }
            foreach (var item in this.StudentClasses)
            {
                int value = 0;
                if (item.year != null)
                {
                    if (int.Parse(item.year) == smallestYear)
                    {
                        switch (item.semester)
                        {
                        case "SPTRING":
                            value = 0;
                            break;

                        case "SUMMER":
                            value = 1;
                            break;

                        case "FALL":
                            value = 2;
                            break;
                        }
                        if (value < smallestSemester)
                        {
                            smallestSemester = value;
                        }
                    }
                }
            }
            semester      = (Semesters)smallestSemester;
            StartSemester = string.Format("{0}", smallestYear) + semester.ToString();
            return(ret);
        }
Beispiel #29
0
 public void AddSemester(SemesterModel model)
 {
     using (SZPNUWContext context = new SZPNUWContext())
     {
         Semesters semester = new Semesters()
         {
             Fieldofstudy   = model.Department,
             Academicyear   = model.Year,
             Semesternumber = model.SemesterNumber
         };
         context.Add(semester);
         context.SaveChanges();
     }
 }
Beispiel #30
0
        //[Bind(Direction.ServerToClient)]
        //public bool ShowSaveButton { get; set; } = false;

        public override async Task PreRender()
        {
            if (Semesters.IsRefreshRequired)
            {
                var semestersList = await _semesterService.GetUpdateable();

                semestersList.ForEach(_ => _.AcademicYear = _utilityService.GetAcademicYear(_.StartDate, _.IsWinter));
                Semesters.LoadFromQueryable(semestersList.AsQueryable());
            }

            //ShowSaveButton = NewSemesters.Any();

            await base.PreRender();
        }
        public void Can_Add_Semesters()
        {
            // Arrange
            var mock = new Mock<ISemestersRepository>();

            SemestersController target = new SemestersController(mock.Object);
            Semesters semester = new Semesters{ SemesterID=1, Type="letni", Year="2007/2008"};
            // Action

            ActionResult result = target.Add(semester);

            // Assert
            mock.Verify(m => m.AddSemester(semester),Times.Once());
            Assert.IsInstanceOfType(typeof(RedirectToRouteResult), result);
            Assert.AreEqual("Pomyślnie dodano nowy semestr!", target.TempData["message"]);
        }
        public void Can_Remove_Semester()
        {
            // Arrange
            Mock<ISemestersRepository> mock = new Mock<ISemestersRepository>();
            Semesters semester = new Semesters { SemesterID = 2, Type = "letni", Year = "2007/2008"};
            mock.Setup(m => m.GetSemesterByID(2)).Returns(semester);
            mock.Setup(m => m.DeleteSemester(semester));
            // Arrange
            SemestersController target = new SemestersController(mock.Object);

            // Act
            var result = target.DeleteConfirmed(2);

            // Assert - check the method result type
            mock.Verify(m => m.DeleteSemester(semester));
            Assert.AreEqual("Usunięto semestr!", target.TempData["message"]);
            Assert.IsInstanceOfType(typeof(RedirectToRouteResult), result);
        }
        public void Can_Edit_Semester()
        {
            // Arrange
            Mock<ISemestersRepository> mock = new Mock<ISemestersRepository>();

            // Arrange
            SemestersController target = new SemestersController(mock.Object);

            // Arrange
            Semesters semester = new Semesters { SemesterID = 1, Type = "letni", Year = "2007/2008" };

            // Act
            ActionResult result = target.Edit(semester);

            // Assert
            mock.Verify(m => m.EditSemester(semester));

            // Assert
            Assert.AreEqual("Zauktalizowano semestr!", target.TempData["message"]);
            Assert.IsInstanceOfType(typeof(RedirectToRouteResult), result);
        }