Esempio n. 1
0
        /// <summary>
        /// Method for setting bell notification on creation of homeworks
        /// </summary>
        /// <param name="homeWork"></param>
        /// <param name="currentUser"></param>
        /// <param name="instituteId"></param>
        /// <returns></returns>
        private async Task SendBellNotificationOnHomewordCreation(AddHomeworkManagementAc homeWork, ApplicationUser currentUser, int instituteId)
        {
            StaffBasicPersonalInformation homeWorkCreatedByStaff = await _iMSDbContext.StaffBasicPersonalInformation
                                                                   .FirstOrDefaultAsync(x => x.UserId == currentUser.Id);

            List <StudentBasicInformation> recipientStudentsList = await _iMSDbContext.StudentBasicInformation
                                                                   .Where(x => x.CurrentClassId == homeWork.ClassId && x.SectionId == homeWork.SectionId && x.IsActive && !x.IsArchived)
                                                                   .ToListAsync();

            NotificationAc notificationAc = new NotificationAc
            {
                NotificationMessage          = "Homework",
                NotificationTo               = null,
                NotificationUserMappingsList = new List <NotificationUserMappingAc>()
            };

            // For students
            notificationAc.NotificationDetails = string.Format("Homework: Complete assignment dated {0}", homeWork.HomeworkDate.ToString("dd-MM-yyyy"));
            foreach (StudentBasicInformation recipientStudent in recipientStudentsList)
            {
                notificationAc.NotificationUserMappingsList.Add(new NotificationUserMappingAc
                {
                    UserId = recipientStudent.UserId
                });
            }
            await _notificationManagementRepository.AddNotificationAsync(notificationAc, instituteId, currentUser);

            notificationAc.NotificationUserMappingsList = new List <NotificationUserMappingAc>();

            if (homeWorkCreatedByStaff != null)
            {
                InstituteClass instituteClass = await _iMSDbContext.InstituteClasses
                                                .Include(x => x.Institute)
                                                .FirstAsync(x => x.Id == homeWork.ClassId);

                // To self
                notificationAc.NotificationDetails = string.Format("You have added homework for {0}", instituteClass.Name);
                notificationAc.NotificationUserMappingsList.Add(new NotificationUserMappingAc
                {
                    UserId = homeWorkCreatedByStaff.UserId
                });

                await _notificationManagementRepository.AddNotificationAsync(notificationAc, instituteId, currentUser);

                notificationAc.NotificationUserMappingsList = new List <NotificationUserMappingAc>();

                // To the admin
                notificationAc.NotificationDetails = string.Format("{0} has added homework for {1}", homeWorkCreatedByStaff.FirstName, instituteClass.Name);
                notificationAc.NotificationUserMappingsList.Add(new NotificationUserMappingAc
                {
                    UserId = instituteClass.Institute.AdminId
                });

                await _notificationManagementRepository.AddNotificationAsync(notificationAc, instituteId, currentUser);

                notificationAc.NotificationUserMappingsList = new List <NotificationUserMappingAc>();
            }
        }
        public async Task <IActionResult> GetTimeTableInitialDataAsync(int classId, int sectionId)
        {
            int loggedInUserInstituteId = await GetUserCurrentSelectedInstituteIdAsync();

            List <WeekDaysEnumDetails>   weekDaysEnumDetailsList = _timeTableManagementRepository.GetDaysOfWeek(loggedInUserInstituteId);
            List <InstituteAcademicYear> academicYears           = await _instituteAcademicYearManagementRepository.GetAcademicYearsListAsync(loggedInUserInstituteId);

            List <InstituteSubject> subjects = await _instituteSubjectManagementRepository.GetAllInstituteSubjectsAsync(loggedInUserInstituteId);

            InstituteClass instituteClass = await _imsDbContext.InstituteClasses.FirstOrDefaultAsync(x => x.Id == classId && x.InstituteId == loggedInUserInstituteId);

            Section section = await _imsDbContext.Sections.FirstOrDefaultAsync(x => x.Id == sectionId && x.InstituteId == loggedInUserInstituteId);

            return(Ok(new { AcademicYears = academicYears.Where(x => x.IsActive), Subjects = subjects, daysOfWeek = weekDaysEnumDetailsList, Class = instituteClass, Section = section }));
        }
Esempio n. 3
0
        /// <summary>
        /// Method for fetching the class-subject mappings by class id
        /// </summary>
        /// <param name="classId"></param>
        /// <param name="currentUser"></param>
        /// <returns></returns>
        public async Task <Tuple <List <StaffBasicPersonalInformation>, List <ClassSubjectMappingAc> > > GetClassSubjectMappingByClassIdAsync(int classId, ApplicationUser currentUser)
        {
            int currentUserInstituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(currentUser.Id, true);

            List <ClassSubjectMappingAc> classSubjectMappingListAc = new List <ClassSubjectMappingAc>();

            InstituteClass instituteClass = await _imsDbContext.InstituteClasses.FirstAsync(x => x.Id == classId);

            List <InstituteClassSubjectMapping> classSubjectMappingsList = await _imsDbContext.InstituteClassSubjectMappings
                                                                           .Include(x => x.InstituteClass)
                                                                           .Include(x => x.InstituteSubject)
                                                                           .Include(x => x.Faculty.User)
                                                                           .Include(x => x.AlternateFaculty.User)
                                                                           .Where(x => x.ClassId == classId && x.InstituteClass.InstituteId == currentUserInstituteId && x.InstituteSubject.InstituteId == currentUserInstituteId).ToListAsync();

            List <InstituteSubject> subjectsList = await _instituteSubjectManagementRepository.GetAllInstituteSubjectsAsync(currentUserInstituteId);

            List <StaffBasicPersonalInformation> facultiesList = await _imsDbContext.StaffBasicPersonalInformation
                                                                 .Where(x => x.InstituteId == currentUserInstituteId && x.IsTeachingStaff)
                                                                 .ToListAsync();

            // Find mappings
            foreach (InstituteSubject subject in subjectsList)
            {
                ClassSubjectMappingAc classSubjectMappingAc = new ClassSubjectMappingAc
                {
                    ClassId     = classId,
                    ClassName   = instituteClass.Name,
                    SubjectId   = subject.Id,
                    SubjectName = subject.Name,
                    IsMapped    = classSubjectMappingsList.Any(x => x.ClassId == classId && x.SubjectId == subject.Id)
                };

                if (classSubjectMappingAc.IsMapped)
                {
                    InstituteClassSubjectMapping classSubjectMapping = classSubjectMappingsList.First(x => x.ClassId == classId && x.SubjectId == subject.Id);
                    classSubjectMappingAc.Id                   = classSubjectMapping.Id;
                    classSubjectMappingAc.FacultyId            = classSubjectMapping.FacultyId;
                    classSubjectMappingAc.AlternateFacultyId   = classSubjectMapping.AlternateFacultyId;
                    classSubjectMappingAc.FacultyName          = classSubjectMapping.Faculty.FirstName;
                    classSubjectMappingAc.AlternateFacultyName = classSubjectMapping.AlternateFaculty.FirstName;
                }

                classSubjectMappingListAc.Add(classSubjectMappingAc);
            }

            return(new Tuple <List <StaffBasicPersonalInformation>, List <ClassSubjectMappingAc> >(facultiesList, classSubjectMappingListAc));
        }
Esempio n. 4
0
        public async Task <IActionResult> GetCourseFeeTermInitialDataAsync(int classId)
        {
            int currentUserInstituteId = await GetUserCurrentSelectedInstituteIdAsync();

            InstituteClass instituteClass = await _imsDbContext.InstituteClasses.FirstOrDefaultAsync(x => x.Id == classId && x.InstituteId == currentUserInstituteId);

            List <Religion> religionsList = await _imsDbContext.Religions.Where(x => x.InstituteId == currentUserInstituteId).ToListAsync();

            List <FeeComponent> feeComponentsList = await _imsDbContext.FeeComponents.Where(x => x.InstituteId == currentUserInstituteId && x.FeeComponentType == FeeComponentTypeEnum.ApplicableToAll).ToListAsync();

            List <InstituteAcademicYear> academicYearsList = await _imsDbContext.InstituteAcademicYears.Where(x => x.InstituteId == currentUserInstituteId).ToListAsync();

            List <CourseFeeTerm> courseFeeTermsList = await _imsDbContext.CourseFeeTerms.Where(x => x.ClassId == classId).ToListAsync();

            return(Ok(new { Class = instituteClass, ReligionsList = religionsList, FeeComponentsList = feeComponentsList, AcademicYearsList = academicYearsList, CourseFeeTermsList = courseFeeTermsList }));
        }
Esempio n. 5
0
        /// <summary>
        /// Method to add institute class - SS
        /// </summary>
        /// <param name="addInstituteClass">class detail</param>
        /// <param name="instituteId">institute id</param>
        /// <returns>message</returns>
        public async Task <InstituteClassResponse> AddInstituteClassAsync(AddInstituteClassManagementAc addInstituteClass, int instituteId)
        {
            if (!await _iMSDbContext.InstituteClasses.AnyAsync(x => x.InstituteId == instituteId &&
                                                               x.GroupCode.ToLowerInvariant() == addInstituteClass.GroupCode.ToLowerInvariant()))
            {
                if (!await _iMSDbContext.StaffBasicPersonalInformation.AnyAsync(x => x.Id == addInstituteClass.ClassTeacherId &&
                                                                                x.InstituteId == instituteId))
                {
                    return new InstituteClassResponse()
                           {
                               HasError = true, Message = "Staff teacher not found", ErrorType = InstituteClassResponseType.ClassTeacherId
                           }
                }
                ;
                else
                {
                    var instituteClass = new InstituteClass()
                    {
                        ClassOrder       = addInstituteClass.ClassOrder,
                        CreatedOn        = DateTime.UtcNow,
                        Duration         = addInstituteClass.Duration,
                        DurationUnit     = addInstituteClass.DurationUnit,
                        GroupCode        = addInstituteClass.GroupCode,
                        InstituteId      = instituteId,
                        IsGroup          = addInstituteClass.IsGroup,
                        Name             = addInstituteClass.Name,
                        NumberOfFeeTerms = addInstituteClass.NumberOfFeeTerms,
                        ClassTeacherId   = addInstituteClass.ClassTeacherId
                    };

                    _iMSDbContext.InstituteClasses.Add(instituteClass);
                    await _iMSDbContext.SaveChangesAsync();

                    return(new InstituteClassResponse()
                    {
                        HasError = false, Message = "Class added successfully"
                    });
                }
            }
            else
            {
                return new InstituteClassResponse()
                       {
                           HasError = true, Message = "Group code already exist", ErrorType = InstituteClassResponseType.GroupCode
                       }
            };
        }
Esempio n. 6
0
        /// <summary>
        /// Method for adding course fee details - RS
        /// </summary>
        /// <param name="addCourseFeeTermAc"></param>
        /// <param name="courseFeeTermId"></param>
        /// <param name="currentUser"></param>
        /// <returns></returns>
        private async Task AddCourseFeeDetailsAsync(AddCourseFeeTermAc addCourseFeeTermAc, int courseFeeTermId, ApplicationUser currentUser)
        {
            List <CourseFeeTermDetails> courseFeeTermDetailsList = new List <CourseFeeTermDetails>();
            InstituteClass instituteClass = await _imsDbContext.InstituteClasses.FirstAsync(x => x.Id == addCourseFeeTermAc.CourseFeeTermAc.ClassId);

            foreach (CourseFeeTermDetailsAc courseFeeTermDetailsAc in addCourseFeeTermAc.CourseFeeTermDetailsList)
            {
                if (addCourseFeeTermAc.Term != 0)
                {
                    courseFeeTermDetailsList.Add(new CourseFeeTermDetails
                    {
                        CourseFeeTermId = courseFeeTermId,
                        FeeComponentId  = courseFeeTermDetailsAc.FeeComponentId,
                        Amount          = courseFeeTermDetailsAc.Amount,
                        Term            = addCourseFeeTermAc.Term,
                        CreatedBy       = currentUser.Id,
                        CreatedOn       = DateTime.UtcNow
                    });
                }
                else
                {
                    for (int i = 0; i < instituteClass.NumberOfFeeTerms; i++)
                    {
                        courseFeeTermDetailsList.Add(new CourseFeeTermDetails
                        {
                            CourseFeeTermId = courseFeeTermId,
                            FeeComponentId  = courseFeeTermDetailsAc.FeeComponentId,
                            Amount          = courseFeeTermDetailsAc.Amount,
                            Term            = i + 1,
                            CreatedBy       = currentUser.Id,
                            CreatedOn       = DateTime.UtcNow
                        });
                    }
                }
            }
            _imsDbContext.CourseFeeTermDetails.AddRange(courseFeeTermDetailsList);
            await _imsDbContext.SaveChangesAsync();
        }