/// <summary>
        /// Method to update student relieving detail - SS
        /// </summary>
        /// <param name="updateStudentRelievings">updated detail</param>
        /// <param name="loggedInUser">logged in user</param>
        /// <returns>response</returns>
        public async Task <StudentRelievingManagementResponse> UpdateStudentRelievingAsync(UpdateStudentRelievingManagementAc updateStudentRelievings, ApplicationUser loggedInUser)
        {
            var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

            var student = await _iMSDbContext.StudentRelievingMappings.FirstOrDefaultAsync(x => x.Id == updateStudentRelievings.Id && x.Student.InstituteId == instituteId);

            if (student == null)
            {
                return new StudentRelievingManagementResponse()
                       {
                           HasError = true, ErrorType = StudentRelievingManagementResponseType.StudentId, Message = "Student not found"
                       }
            }
            ;
            else
            {
                student.Reason = updateStudentRelievings.Reason;

                student.RelievingDate    = updateStudentRelievings.RelievingDate;
                student.StudentRelieving = EnumHelperService.GetValueFromDescription <StudentRelievingEnum>(updateStudentRelievings.StudentRelieving);
                student.UpdatedOn        = DateTime.UtcNow;
                student.UpdatedById      = loggedInUser.Id;
                _iMSDbContext.StudentRelievingMappings.Update(student);
                await _iMSDbContext.SaveChangesAsync();

                return(new StudentRelievingManagementResponse()
                {
                    HasError = false, Message = "Student details updated successfully"
                });
            }
        }
        /// <summary>
        /// Method to update auto sequence - SS
        /// </summary>
        /// <param name="updateAutoSequence">auto sequence</param>
        /// <param name="loggedInUser">logged in user detail</param>
        /// <returns>response</returns>
        public async Task <AutoSequenceGeneratorManagementResponse> UpdateAutoSequenceGeneratorAsync(UpdateAutoSequenceGeneratorManagementAc
                                                                                                     updateAutoSequence, ApplicationUser loggedInUser)
        {
            await semaphore.WaitAsync();

            try
            {
                var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

                var autoSequence = await _iMSDbContext.AutoSequenceGenerators.FirstOrDefaultAsync(x => x.Id == updateAutoSequence.Id &&
                                                                                                  x.InstituteId == instituteId);

                if (autoSequence != null)
                {
                    if (updateAutoSequence.AutoSequenceGeneratorDataTypes.Any(x => x.IsSelected && x.Name == "Text"))
                    {
                        if (string.IsNullOrEmpty(updateAutoSequence.CustomText))
                        {
                            return new AutoSequenceGeneratorManagementResponse()
                                   {
                                       HasError = true, Message = "Please add text in custom text."
                                   }
                        }
                        ;
                    }
                    autoSequence.CustomText = updateAutoSequence.CustomText;
                    autoSequence.Seperator  = EnumHelperService.GetValueFromDescription <AutoSequenceGeneratorSeperatorEnum>(updateAutoSequence.SeperatorDescription);
                    autoSequence.UpdateById = loggedInUser.Id;
                    autoSequence.UpdateDate = DateTime.UtcNow;
                    autoSequence.AutoSequenceGeneratorDataTypes = null;
                    _iMSDbContext.AutoSequenceGenerators.Update(autoSequence);
                    await _iMSDbContext.SaveChangesAsync();

                    var types = await _iMSDbContext.AutoSequenceGeneratorDataTypes.Where(x => x.AutoSequenceGeneratorId == autoSequence.Id).ToListAsync();

                    _iMSDbContext.AutoSequenceGeneratorDataTypes.RemoveRange(types);
                    await _iMSDbContext.SaveChangesAsync();

                    updateAutoSequence.AutoSequenceGeneratorDataTypes.ForEach(x => x.Id = 0);
                    _iMSDbContext.AutoSequenceGeneratorDataTypes.AddRange(updateAutoSequence.AutoSequenceGeneratorDataTypes);
                    await _iMSDbContext.SaveChangesAsync();

                    return(new AutoSequenceGeneratorManagementResponse()
                    {
                        HasError = false, Message = "Auto sequence updated successfully"
                    });
                }
                else
                {
                    return new AutoSequenceGeneratorManagementResponse()
                           {
                               HasError = true, Message = "Auto sequence not found"
                           }
                };
            }
            finally
            {
                semaphore.Release();
            }
        }
        /// <summary>
        /// Method to add or update Vehicle document - SS
        /// </summary>
        /// <param name="files">image files</param>
        /// <param name="vehicleId">Vehicle id</param>
        /// <param name="loggedInUser">logged in user</param>
        /// <param name="addVehicleDocuments">documnets details</param>
        public async Task AddOrUpdateVehicleDocumentsAsync(IFormFileCollection files, int vehicleId, ApplicationUser loggedInUser,
                                                           List <AddVehicleDocumentMappingAc> addVehicleDocuments)
        {
            var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

            var instituteName = (await _iMSDbContext.Institutes.FirstAsync(x => x.Id == instituteId)).Name;
            var images        = await _imageStorageHelperService.UploadBlobDataAsync(files, instituteName, "Document");

            if (images.Count != 0)
            {
                var gallery = new List <VehicleDocumentMapping>();
                for (int i = 0; i < images.Count; i++)
                {
                    gallery.Add(new VehicleDocumentMapping()
                    {
                        CreatedOn   = DateTime.UtcNow,
                        ExpiredDate = addVehicleDocuments[i].ExpiredDate,
                        FileType    = EnumHelperService.GetValueFromDescription <FileTypeEnum>(addVehicleDocuments[i].FileType),
                        FileUrl     = images[i],
                        MetaData    = addVehicleDocuments[i].MetaData,
                        VehicleId   = vehicleId,
                        Name        = addVehicleDocuments[i].Name
                    });
                }
                _iMSDbContext.VehicleDocumentMappings.AddRange(gallery);
                await _iMSDbContext.SaveChangesAsync();
            }
        }
        /// <summary>
        /// Method to add bulk student relieving details
        /// </summary>
        /// <param name="addStudentRelievings">student detail</param>
        /// <param name="loggedInUser">logged in user</param>
        /// <returns>response</returns>
        public async Task <StudentRelievingManagementResponse> AddStudentRelievingAsync(List <AddStudentRelievingManagementAc> addStudentRelievings, ApplicationUser loggedInUser)
        {
            List <StudentRelievingMapping> studentRelievingMappings = new List <StudentRelievingMapping>();

            foreach (var addStudentRelieving in addStudentRelievings)
            {
                var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

                studentRelievingMappings.Add(new StudentRelievingMapping()
                {
                    CreatedOn        = DateTime.UtcNow,
                    Reason           = addStudentRelieving.Reason,
                    RelievingDate    = addStudentRelieving.RelievingDate,
                    StudentId        = addStudentRelieving.StudentId,
                    StudentRelieving = EnumHelperService.GetValueFromDescription <StudentRelievingEnum>(addStudentRelieving.StudentRelieving),
                    UpdatedById      = loggedInUser.Id,
                    UpdatedOn        = DateTime.UtcNow
                });
            }
            _iMSDbContext.StudentRelievingMappings.AddRange(studentRelievingMappings);
            await _iMSDbContext.SaveChangesAsync();

            return(new StudentRelievingManagementResponse()
            {
                Message = "Student details updated successfully", HasError = false
            });
        }
示例#5
0
        /// <summary>
        /// Method to get list of leave types - SS
        /// </summary>
        /// <param name="instituteId">institute id</param>
        /// <returns>list of leave types</returns>
        public async Task <List <LeaveType> > GetLeaveTypesAsync(int instituteId)
        {
            var list = await _iMSDbContext.LeaveTypes.Where(x => x.InstituteId == instituteId).ToListAsync();

            list.ForEach(x => x.LeaveAssignedTypeEnumDescription = EnumHelperService.GetDescription(x.LeaveAssignedTypeEnum));
            return(list);
        }
        /// <summary>
        /// Method for fetching the list off holidays by selected academic year
        /// </summary>
        /// <param name="academicYearId"></param>
        /// <returns></returns>
        public async Task <List <InstituteHolidayAc> > GetHolidaysByAcademicYearIdAsync(int academicYearId, ApplicationUser currentUser)
        {
            int currentUserInstituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(currentUser.Id, true);

            List <Holiday> holidaysList = await _imsDbContext.Holidays.Where(x => x.InstitutionId == currentUserInstituteId && x.AcademicYearId == academicYearId).ToListAsync();

            List <InstituteHolidayAc> holidaysListAc = new List <InstituteHolidayAc>();

            foreach (Holiday holiday in holidaysList)
            {
                holidaysListAc.Add(new InstituteHolidayAc
                {
                    Id                  = holiday.Id,
                    AcademicYearId      = holiday.AcademicYearId,
                    InstitutionId       = holiday.InstitutionId,
                    HolidayDate         = holiday.HolidayDate,
                    HolidayToDate       = holiday.HolidayToDate,
                    Description         = holiday.Description,
                    OccuranceType       = holiday.OccuranceType,
                    OccuranceTypeString = EnumHelperService.GetDescription(holiday.OccuranceType)
                });
            }

            return(holidaysListAc);
        }
        /// <summary>
        /// Method for fetching the list of all circular/notice - RS
        /// </summary>
        /// <param name="currentUserInstituteId"></param>
        /// <returns></returns>
        public async Task <List <CircularNoticeAc> > GetAllCircularNoticeAsync(int currentUserInstituteId)
        {
            List <CircularNotice> circularNoticeList = await _imsDbContext.CircularNotices
                                                       .Where(x => x.InstituteId == currentUserInstituteId)
                                                       .Include(x => x.CircularNoticeRecipients)
                                                       .ToListAsync();

            List <CircularNoticeAc> circularNoticeAcList = new List <CircularNoticeAc>();

            foreach (CircularNotice circularNotice in circularNoticeList)
            {
                circularNoticeAcList.Add(new CircularNoticeAc
                {
                    Id               = circularNotice.Id,
                    Description      = circularNotice.Description,
                    Message          = circularNotice.Message,
                    NoticeDate       = circularNotice.NoticeDate,
                    NoticeTo         = circularNotice.NoticeTo,
                    NoticeToString   = EnumHelperService.GetDescription(circularNotice.NoticeTo),
                    NoticeType       = circularNotice.NoticeType,
                    NoticeTypeString = EnumHelperService.GetDescription(circularNotice.NoticeType)
                });
            }

            return(circularNoticeAcList);
        }
示例#8
0
        /// <summary>
        /// Method to get all fee receipt - SS
        /// </summary>
        /// <param name="instituteId">institue id</param>
        /// <returns>list of fee receipts</returns>
        public async Task <List <FeeReceipt> > GetAllFeeReceiptsAsync(int instituteId)
        {
            var list = await _iMSDbContext.FeeReceipts.Include(s => s.Student).Where(x => x.Student.InstituteId == instituteId).ToListAsync();

            list.ForEach(x => x.ReceiptTypeDescription = EnumHelperService.GetDescription(x.ReceiptType));
            return(list);
        }
        public async Task <IActionResult> GetStudentAttendanceForStudentDashboardAsync([FromBody] GetStudentAttendanceForStudentDashboardAc attendance)
        {
            var instituteId = await GetUserCurrentSelectedInstituteIdAsync();

            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var student = await _iMSDbContext.StudentBasicInformation.FirstOrDefaultAsync(x => x.UserId == user.Id && x.InstituteId == instituteId);

            List <StudentAttendance> attendances = new List <StudentAttendance>();

            if (student != null)
            {
                var academicYear = await _iMSDbContext.InstituteAcademicYears.FirstOrDefaultAsync(x => x.InstituteId == instituteId && x.IsActive);

                attendances = await _iMSDbContext.StudentAttendances.Where(x => x.StudentId == student.Id && x.AttendanceDate >= attendance.FromDate &&
                                                                           x.AttendanceDate <= attendance.EndDate && x.PeriodOrderId == 0).ToListAsync();

                if (academicYear != null)
                {
                    attendances = attendances.Where(x => x.AcademicYearId == academicYear.Id).ToList();
                }
                attendances.ForEach(x => x.AttendanceTypeDescription = EnumHelperService.GetDescription(x.AttendanceType));
            }
            return(Ok(attendances));
        }
示例#10
0
        /// <summary>
        /// Method for fetching the list of all chart of accounts - RS
        /// </summary>
        /// <param name="currentUserInstituteId"></param>
        /// <returns></returns>
        public async Task <List <ChartOfAccountsListViewAC> > GetChartOfAccountsListAsync(int currentUserInstituteId)
        {
            List <ChartOfAccountTypeEnum> chartOfAccountTypeEnumDetailsList = EnumHelperService.GetEnumValuesList <ChartOfAccountTypeEnum>();
            List <FinanceChartOfAccounts> chartsOfAccountsList = await _imsDbContext.FinanceChartOfAccounts
                                                                 .Where(x => x.InstituteId == currentUserInstituteId)
                                                                 .Include(x => x.Institute)
                                                                 .ToListAsync();

            List <ChartOfAccountsListViewAC> chartOfAccountsListView = new List <ChartOfAccountsListViewAC>();

            foreach (ChartOfAccountTypeEnum chartOfAccountTypeEnum in chartOfAccountTypeEnumDetailsList)
            {
                // Set account types and parent accounts
                ChartOfAccountsListViewAC chartOfAccountsListViewAc = new ChartOfAccountsListViewAC
                {
                    ChartOfAccountTypeEnum       = chartOfAccountTypeEnum,
                    ChartOfAccountTypeEnumString = EnumHelperService.GetDescription(chartOfAccountTypeEnum),
                    ParentChartOfAccounts        = MapChartOfAccountToApplicationClassList(chartsOfAccountsList.FindAll(x => x.AccountType == chartOfAccountTypeEnum && x.IsParent))
                };

                // Set child accounts
                foreach (ChartOfAccountsAC parentChartOfAccount in chartOfAccountsListViewAc.ParentChartOfAccounts)
                {
                    parentChartOfAccount.ChildChartOfAccounts = MapChartOfAccountToApplicationClassList(
                        chartsOfAccountsList.FindAll(x => x.AccountType == chartOfAccountTypeEnum && !x.IsParent && x.ParentGroupId == parentChartOfAccount.Id));
                }

                chartOfAccountsListView.Add(chartOfAccountsListViewAc);
            }

            return(chartOfAccountsListView);
        }
示例#11
0
        public async Task <IActionResult> UpdateDocumentDataAsync([FromBody] List <AddStudentDocumentMappingAc> studentDocuments, int studentId)
        {
            var documents = await _iMSDbContext.StudentDocumentMappings.Where(x => x.StudentId == studentId).ToListAsync();

            _iMSDbContext.StudentDocumentMappings.RemoveRange(documents);
            await _iMSDbContext.SaveChangesAsync();

            List <StudentDocumentMapping> studentDocumentMappings = new List <StudentDocumentMapping>();

            foreach (var doc in studentDocuments)
            {
                studentDocumentMappings.Add(new StudentDocumentMapping()
                {
                    CreatedOn   = DateTime.UtcNow,
                    ExpiredDate = doc.ExpiredDate,
                    FileType    = EnumHelperService.GetValueFromDescription <FileTypeEnum>(doc.FileType),
                    FileUrl     = doc.FileUrl,
                    MetaData    = doc.MetaData,
                    Name        = doc.Name,
                    StudentId   = studentId
                });
            }
            _iMSDbContext.StudentDocumentMappings.AddRange(studentDocumentMappings);
            await _iMSDbContext.SaveChangesAsync();

            return(Ok());
        }
示例#12
0
        public async Task <IActionResult> GetInitialDataForReportsAsync()
        {
            var instituteId = await GetUserCurrentSelectedInstituteIdAsync();

            var classes = await _iMSDbContext.InstituteClasses.Where(x => x.InstituteId == instituteId).ToListAsync();

            var religions = await _iMSDbContext.Religions.Where(x => x.InstituteId == instituteId).ToListAsync();

            var classSubjectMapping = await _iMSDbContext.InstituteClassSubjectMappings.Where(x => x.InstituteClass.InstituteId == instituteId).ToListAsync();

            var teachingStaffs = await _iMSDbContext.TeachingStaffs.Where(x => x.InstituteId == instituteId).ToListAsync();

            var academicYears = await _iMSDbContext.InstituteAcademicYears.Where(x => x.InstituteId == instituteId).ToListAsync();

            var subjects = await _iMSDbContext.InstituteSubjects.Where(x => x.InstituteId == instituteId).ToListAsync();

            var currentYear = academicYears.FirstOrDefault(x => x.IsActive);
            var attendances = await _iMSDbContext.StaffAttendances.Where(x => x.Staff.InstituteId == instituteId).ToListAsync();

            if (currentYear != null)
            {
                attendances = attendances.Where(x => x.AcademicYearId == currentYear.Id).ToList();
            }
            attendances.ForEach(x => x.AttendanceTypeDescription = EnumHelperService.GetDescription(x.AttendanceType));
            var notices = await _iMSDbContext.CircularNotices.Where(x => x.InstituteId == instituteId).ToListAsync();

            var homeworks = await _iMSDbContext.Homeworks.Include(s => s.HomeworkMessageMappings).Where(x => x.Class.InstituteId == instituteId).ToListAsync();

            var allowedDates = await GetAttendanceDaysAsync(instituteId);

            return(Ok(new { classes, religions, classSubjectMapping, teachingStaffs, academicYears, subjects, attendances, notices, homeworks, allowedDates }));
        }
示例#13
0
        /// <summary>
        /// Method for generating event reports - RS
        /// </summary>
        /// <param name="eventManagementReportQueryAc"></param>
        /// <param name="currentUserInstituteId"></param>
        /// <returns></returns>
        public async Task <EventManagementReportResponseAc> GenerateEventReportAsync(EventManagementReportQueryAc eventManagementReportQueryAc, int currentUserInstituteId)
        {
            #region Fetch details

            List <EventReportAc>     eventReportAcList      = new List <EventReportAc>();
            List <EventReportDetail> eventReportDetailsList = await _imsDbContext.EventReportDetails
                                                              .Where(x => x.InstituteId == currentUserInstituteId && x.SentOn.Date >= eventManagementReportQueryAc.StartDate.Date && x.SentOn.Date <= eventManagementReportQueryAc.EndDate.Date)
                                                              .ToListAsync();

            foreach (EventReportDetail eventReportDetail in eventReportDetailsList)
            {
                eventReportAcList.Add(new EventReportAc
                {
                    Format  = EnumHelperService.GetDescription(eventReportDetail.TemplateFormat),
                    To      = eventReportDetail.To,
                    Subject = eventReportDetail.Subject,
                    Message = eventReportDetail.Message,
                    SentOn  = eventReportDetail.SentOn.ToString("dd-MMM-yyyy")
                });
            }

            #endregion

            #region Generate file

            string fileName = "Event_Report_" + DateTime.Now.Day.ToString("00") + "_" + DateTime.Now.Month.ToString("00") + "_" + DateTime.Now.Year.ToString("0000") + ".xlsx";
            return(new EventManagementReportResponseAc()
            {
                FileName = fileName,
                ResponseType = "application/ms-excel",
                FileByteArray = ExcelHelperService.GenerateExcelFromList(eventReportAcList, string.Empty)
            });

            #endregion
        }
        /// <summary>
        /// Method to add or update attendance - SS
        /// </summary>
        /// <param name="staffAttendances">Staff attendance detail</param>
        /// <param name="loggedInUser">logged in user</param>
        public async Task AddStaffAttendanceAsync(List <AddStaffAttendanceManagementWrapperAc> staffAttendances, ApplicationUser loggedInUser)
        {
            var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

            var academicYear = await _iMSDbContext.InstituteAcademicYears.FirstOrDefaultAsync(x => x.InstituteId == instituteId && x.IsActive);

            List <StaffAttendance> toBeDeleted = new List <StaffAttendance>();
            List <StaffAttendance> toBeAdded   = new List <StaffAttendance>();

            foreach (var attendance in staffAttendances)
            {
                toBeDeleted.AddRange(await _iMSDbContext.StaffAttendances.Where(x => x.StaffId == attendance.StaffId &&
                                                                                x.AttendanceDate >= attendance.AttendanceDates.First() && x.AttendanceDate <= attendance.AttendanceDates.Last()).ToListAsync());
                for (int i = 0; i < attendance.AttendanceDates.Count; i++)
                {
                    toBeAdded.Add(new StaffAttendance()
                    {
                        AttendanceDate = attendance.AttendanceDates[i],
                        AttendanceType = EnumHelperService.GetValueFromDescription <AttendanceType>(attendance.AttendanceType[i]),
                        CreatedOn      = DateTime.UtcNow,
                        StaffId        = attendance.StaffId,
                        UpdatedById    = loggedInUser.Id,
                        UpdatedOn      = DateTime.UtcNow,
                        AcademicYearId = academicYear?.Id
                    });
                }
            }
            _iMSDbContext.StaffAttendances.RemoveRange(toBeDeleted);
            _iMSDbContext.StaffAttendances.AddRange(toBeAdded);
            await _iMSDbContext.SaveChangesAsync();
        }
        public async Task <IActionResult> GetSequenceGeneratorsAsync(string generatorType)
        {
            var loggedInUser = await _userManager.FindByNameAsync(User.Identity.Name);

            var generatorTypeEnum = EnumHelperService.GetValueFromDescription <AutoSequenceGeneratorTypeEnum>(generatorType);

            return(Ok(await _autoSequenceGeneratorManagementRepository.GetSequenceGeneratorsAsync(loggedInUser, generatorTypeEnum)));
        }
        public async Task <IActionResult> GetAutoSequenceNumberByTypeAndInstituteIdAsync(string typeEnum)
        {
            var instituteId = await GetUserCurrentSelectedInstituteIdAsync();

            var generatorTypeEnum = EnumHelperService.GetValueFromDescription <AutoSequenceGeneratorTypeEnum>(typeEnum);

            return(Ok(await _autoSequenceGeneratorManagementRepository.GetAutoSequenceNumberByTypeAndInstituteIdAsync(instituteId, generatorTypeEnum)));
        }
示例#17
0
        /// <summary>
        /// Method to get template - SS
        /// </summary>
        /// <param name="getTemplate">query params</param>
        /// <param name="instituteId">institute id</param>
        /// <returns></returns>
        public async Task <Template> GetTemplateAsync(GetTemplateAc getTemplate, int instituteId)
        {
            var template = await _iMSDbContext.Templates.FirstOrDefaultAsync(x => x.TemplateFormat ==
                                                                             EnumHelperService.GetValueFromDescription <TemplateFormatEnum>(getTemplate.TemplateFormat) && x.InstituteId == instituteId &&
                                                                             x.TemplateFeatureType == EnumHelperService.GetValueFromDescription <TemplateFeatureEnum>(getTemplate.TemplateFeatureType) &&
                                                                             x.TemplateType == EnumHelperService.GetValueFromDescription <TemplateTypeEnum>(getTemplate.TemplateType));

            return(template);
        }
        public async Task <IActionResult> GetLeaveTypeAsync(int leaveTypeId)
        {
            var instituteId = await GetUserCurrentSelectedInstituteIdAsync();

            var leaveType = await _iMSDbContext.LeaveTypes.Include(s => s.LeaveAssignedTos).FirstOrDefaultAsync(x => x.Id == leaveTypeId && x.InstituteId == instituteId);

            leaveType.LeaveAssignedTypeEnumDescription = EnumHelperService.GetDescription(leaveType.LeaveAssignedTypeEnum);
            return(Ok(leaveType));
        }
        /// <summary>
        /// Method for fetching an activity by id
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="currentUser"></param>
        /// <returns></returns>
        public async Task <StaffPlannerAc> GetStaffPlanByIdAsync(int plannerId, ApplicationUser currentUser)
        {
            int currentUserInstituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(currentUser.Id, true);

            StaffPlanner staffPlan = await _imsDbContext.StaffPlanners
                                     .Include(x => x.Staff)
                                     .Include(x => x.PlannerAttendeeMappings)
                                     .FirstOrDefaultAsync(x => x.Id == plannerId && x.InstituteId == currentUserInstituteId);

            StaffPlannerAc staffPlanAc = new StaffPlannerAc
            {
                Id                  = staffPlan.Id,
                Name                = staffPlan.Name,
                Description         = staffPlan.Description,
                DateOfPlan          = staffPlan.DateOfPlan,
                IsActive            = staffPlan.IsActive,
                StaffId             = staffPlan.StaffId,
                StaffName           = staffPlan.Staff.FirstName,
                InstituteId         = staffPlan.InstituteId,
                PlannerAttendeeList = new List <StaffPlannerAttendeeMappingAc>()
            };

            List <ApplicationUser> plannerAttendeesList = await _imsDbContext.PlannerAttendeeMappings
                                                          .Where(x => x.PlannerId == plannerId)
                                                          .Include(x => x.Attendee)
                                                          .Select(x => x.Attendee)
                                                          .ToListAsync();

            List <StudentBasicInformation> studentBasicInformationList = await _imsDbContext.StudentBasicInformation.Where(x => x.InstituteId == currentUserInstituteId).ToListAsync();

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

            foreach (PlannerAttendeeMapping plannerAttendeeMapping in staffPlan.PlannerAttendeeMappings)
            {
                string attendeeName = plannerAttendeesList.FirstOrDefault(x => x.Id == plannerAttendeeMapping.AttendeeId)?.Name;
                if (plannerAttendeeMapping.ActivityAttendeeType == ActivityAttendeeTypeEnum.Staff)
                {
                    attendeeName = staffBasicPersonalInformationList.FirstOrDefault(x => x.UserId == plannerAttendeeMapping.AttendeeId).FirstName;
                }
                else if (plannerAttendeeMapping.ActivityAttendeeType == ActivityAttendeeTypeEnum.Student)
                {
                    attendeeName = studentBasicInformationList.FirstOrDefault(x => x.UserId == plannerAttendeeMapping.AttendeeId).FirstName;
                }

                staffPlanAc.PlannerAttendeeList.Add(new StaffPlannerAttendeeMappingAc
                {
                    PlannerId                 = staffPlan.Id,
                    PlannerName               = staffPlan.Name,
                    PlannerAttendeeType       = plannerAttendeeMapping.ActivityAttendeeType,
                    PlannerAttendeeTypeString = EnumHelperService.GetDescription(plannerAttendeeMapping.ActivityAttendeeType),
                    AttendeeId                = plannerAttendeeMapping.AttendeeId,
                    AttendeeName              = attendeeName
                });
            }

            return(staffPlanAc);
        }
        /// <summary>
        /// Method to get vehicles list
        /// </summary>
        /// <param name="instituteId">institute id</param>
        /// <returns>list of vehicles</returns>
        public async Task <List <VehicleMaster> > GetVehicleMastersAsync(int instituteId)
        {
            var list = await _iMSDbContext.VehicleMasters.Where(x => x.InstituteId == instituteId).ToListAsync();

            list.ForEach(x =>
            {
                x.FuelTypeDescription    = EnumHelperService.GetDescription(x.FuelType);
                x.VehicleTypeDescription = EnumHelperService.GetDescription(x.VehicleType);
            });
            return(list);
        }
示例#21
0
        /// <summary>
        /// Method for adding a new template - RS
        /// </summary>
        /// <param name="addedTemplate"></param>
        /// <param name="currentUser"></param>
        /// <returns></returns>
        public async Task <dynamic> AddOrUpdateTemplateAsync(AddTemplateAc addedTemplate, ApplicationUser currentUser)
        {
            if (string.IsNullOrEmpty(addedTemplate.Name.Trim()))
            {
                return new { HasError = true, Message = "Name can't be empty" }
            }
            ;
            else if (string.IsNullOrEmpty(addedTemplate.Format.Trim()))
            {
                return new { HasError = true, Message = "Format can't be empty" }
            }
            ;
            else
            {
                var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(currentUser.Id, true);

                var template = await _iMSDbContext.Templates.FirstOrDefaultAsync(x => x.TemplateFormat ==
                                                                                 EnumHelperService.GetValueFromDescription <TemplateFormatEnum>(addedTemplate.TemplateFormat) && x.InstituteId == instituteId &&
                                                                                 x.TemplateFeatureType == EnumHelperService.GetValueFromDescription <TemplateFeatureEnum>(addedTemplate.TemplateFeatureType) &&
                                                                                 x.TemplateType == EnumHelperService.GetValueFromDescription <TemplateTypeEnum>(addedTemplate.TemplateType));

                if (template == null)
                {
                    template = new Template
                    {
                        CreatedOn           = DateTime.UtcNow,
                        EmailBcc            = addedTemplate.EmailBcc,
                        EmailSubject        = addedTemplate.EmailSubject,
                        To                  = addedTemplate.To,
                        Name                = addedTemplate.Name,
                        TemplateFormat      = EnumHelperService.GetValueFromDescription <TemplateFormatEnum>(addedTemplate.TemplateFormat),
                        TemplateFeatureType = EnumHelperService.GetValueFromDescription <TemplateFeatureEnum>(addedTemplate.TemplateFeatureType),
                        TemplateType        = EnumHelperService.GetValueFromDescription <TemplateTypeEnum>(addedTemplate.TemplateType),
                        Format              = addedTemplate.Format,
                        InstituteId         = instituteId
                    };
                    _iMSDbContext.Templates.Add(template);
                    await _iMSDbContext.SaveChangesAsync();
                }
                else
                {
                    template.EmailBcc     = addedTemplate.EmailBcc;
                    template.EmailSubject = addedTemplate.EmailSubject;
                    template.To           = addedTemplate.To;
                    template.Name         = addedTemplate.Name;
                    template.Format       = addedTemplate.Format;
                    _iMSDbContext.Templates.Add(template);
                    await _iMSDbContext.SaveChangesAsync();
                }
                return(new { HasError = false, Message = "Template updated successfully" });
            }
        }
 /// <summary>
 /// Method to get all feature list by user group id - SS
 /// </summary>
 /// <param name="userGroupId">user group id</param>
 /// <returns>list of user group feature</returns>
 public async Task<List<UserGroupFeature>> GetAllUserGroupFeaturesByUserGroupIdAsync(int userGroupId)
 {
     await SeedingUserGroupFeaturesAsync(userGroupId);
     var list = await _iMSDbContext.UserGroupFeatures.OrderByDescending(c => c.UserGroupFeatureParent).Where(x => x.UserGroupId == userGroupId).ToListAsync();
     list.Reverse();
     list.ForEach(x =>
     {
         x.UserGroupFeatureChildDescription = EnumHelperService.GetDescription(x.UserGroupFeatureChild);
         x.UserGroup = null;
         x.UserGroupFeatureParentDescription = EnumHelperService.GetDescription(x.UserGroupFeatureParent);
     });
     return list;
 }
        /// <summary>
        /// Method to get auto sequence data - SS
        /// </summary>
        /// <param name="loggedInUser">logged in user detail</param>
        /// <param name="generatorTypeEnum">auto sequence type</param>
        /// <returns>auto sequence data</returns>
        public async Task <AutoSequenceGenerator> GetSequenceGeneratorsAsync(ApplicationUser loggedInUser, AutoSequenceGeneratorTypeEnum generatorTypeEnum)
        {
            var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

            await SeedDataForAutoSequenceByTypeAsync(instituteId, loggedInUser.Id, generatorTypeEnum);

            var autoSequence = await _iMSDbContext.AutoSequenceGenerators.Include(x => x.AutoSequenceGeneratorDataTypes)
                               .FirstAsync(x => x.AutoSequenceGeneratorType == generatorTypeEnum && x.InstituteId == instituteId);

            autoSequence.SeperatorDescription           = EnumHelperService.GetDescription(autoSequence.Seperator);
            autoSequence.AutoSequenceGeneratorDataTypes = autoSequence.AutoSequenceGeneratorDataTypes.OrderByDescending(x => x.OrderId).ToList();
            autoSequence.AutoSequenceGeneratorDataTypes = autoSequence.AutoSequenceGeneratorDataTypes.Reverse().ToList();
            return(autoSequence);
        }
        /// <summary>
        /// Method for fetching the list of all occurance types
        /// </summary>
        /// <returns></returns>
        public List <HolidayOccuranceTypeEnumDetailsListAc> GetOccuranceTypesList()
        {
            List <HolidayOccuranceTypeEnum> occuranceTypeEnumList = EnumHelperService.GetEnumValuesList <HolidayOccuranceTypeEnum>();
            List <HolidayOccuranceTypeEnumDetailsListAc> occuranceTypeEnumDetailsList = new List <HolidayOccuranceTypeEnumDetailsListAc>();

            foreach (HolidayOccuranceTypeEnum holidayOccuranceType in occuranceTypeEnumList)
            {
                occuranceTypeEnumDetailsList.Add(new HolidayOccuranceTypeEnumDetailsListAc
                {
                    HolidayOccuranceTypeEnum       = holidayOccuranceType,
                    HolidayOccuranceTypeEnumString = EnumHelperService.GetDescription(holidayOccuranceType)
                });
            }

            return(occuranceTypeEnumDetailsList);
        }
        /// <summary>
        /// Method to get all student from relieving table - SS
        /// </summary>
        /// <param name="instituteId">institute id</param>
        /// <returns>list of student</returns>
        public async Task <List <StudentRelievingMapping> > GetAllStudentRelievingMappingsAsync(ApplicationUser loggedInUser)
        {
            var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

            var academicYear = await _iMSDbContext.SelectedAcademicYears.FirstOrDefaultAsync(x => x.UserId == loggedInUser.Id &&
                                                                                             x.AcademicYear.InstituteId == instituteId);

            var list = await _iMSDbContext.StudentRelievingMappings.Include(s => s.Student).Where(x => x.Student.InstituteId == instituteId).ToListAsync();

            list.ForEach(x => x.StudentRelievingDescription = EnumHelperService.GetDescription(x.StudentRelieving));
            if (academicYear != null)
            {
                list = list.Where(x => x.Student.CurrentAcademicYearId == academicYear.AcademicYearId).ToList();
            }
            return(list);
        }
示例#26
0
        public async Task <IActionResult> GetFeeReceiptsByIdAsync(int feeReceiptId)
        {
            var instituteId = await GetUserCurrentSelectedInstituteIdAsync();

            var feeReceipt = await _imsDbContext.FeeReceipts.Include(s => s.FeeReceiptComponents).FirstOrDefaultAsync(x => x.Id == feeReceiptId &&
                                                                                                                      x.Student.InstituteId == instituteId);

            if (feeReceipt != null)
            {
                feeReceipt.ReceiptTypeDescription = EnumHelperService.GetDescription(feeReceipt.ReceiptType);
                return(Ok(feeReceipt));
            }
            else
            {
                return(Ok(new { Message = "Fee receipt not found" }));
            }
        }
        public async Task <IActionResult> GetVehicleMasterAsync(int vehicleId)
        {
            var instituteId = await GetUserCurrentSelectedInstituteIdAsync();

            var vehicle = await _imsDbContext.VehicleMasters.Include(s => s.VehicleDocumentMappings).FirstOrDefaultAsync(x => x.Id == vehicleId && x.InstituteId == instituteId);

            if (vehicle != null)
            {
                vehicle.FuelTypeDescription    = EnumHelperService.GetDescription(vehicle.FuelType);
                vehicle.VehicleTypeDescription = EnumHelperService.GetDescription(vehicle.VehicleType);
                return(Ok(vehicle));
            }
            else
            {
                return(Ok(new { Message = "Vehicle not found" }));
            }
        }
        /// <summary>
        /// Method for fetching the details of the holiday
        /// </summary>
        /// <param name="holidayId"></param>
        /// <param name="currentUser"></param>
        /// <returns></returns>
        public async Task <AddHolidayAc> GetHolidayDetailsByIdAsync(int holidayId, ApplicationUser currentUser)
        {
            int currentUserInstituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(currentUser.Id, true);

            Holiday holiday = await _imsDbContext.Holidays.FirstOrDefaultAsync(x => x.Id == holidayId && x.InstitutionId == currentUserInstituteId);

            return(new AddHolidayAc
            {
                Id = holiday.Id,
                AcademicYearId = holiday.AcademicYearId,
                Description = holiday.Description,
                FromDate = holiday.HolidayDate,
                ToDate = holiday.HolidayToDate,
                OccuranceType = holiday.OccuranceType,
                OccuranceTypeString = EnumHelperService.GetDescription(holiday.OccuranceType)
            });
        }
        /// <summary>
        /// Method to get Staff details - SS
        /// </summary>
        /// <param name="getStaffAttendance">query data</param>
        /// <param name="loggedInUser">logged in user</param>
        /// <returns>list of Staff attendance</returns>
        public async Task <List <StaffAttendance> > GetStaffAttendanceAsync(GetStaffAttendanceManagementAc getStaffAttendance, ApplicationUser loggedInUser)
        {
            var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

            var academicYear = await _iMSDbContext.SelectedAcademicYears.FirstOrDefaultAsync(x => x.AcademicYear.InstituteId == instituteId &&
                                                                                             x.UserId == loggedInUser.Id);

            var attendances = await _iMSDbContext.StaffAttendances.Where(x => x.AttendanceDate >= getStaffAttendance.StartDate &&
                                                                         x.AttendanceDate <= getStaffAttendance.EndDate).ToListAsync();

            if (academicYear != null)
            {
                attendances = attendances.Where(x => x.AcademicYearId == academicYear.AcademicYearId).ToList();
            }
            attendances.ForEach(x => x.AttendanceTypeDescription = EnumHelperService.GetDescription(x.AttendanceType));
            return(attendances);
        }
示例#30
0
        public async Task <IActionResult> GetStudentRelievingDetailByIdAsync(int relievingId)
        {
            var loggedInUserInstituteId = await GetUserCurrentSelectedInstituteIdAsync();

            var relieving = await _iMSDbContext.StudentRelievingMappings.Include(s => s.Student).FirstOrDefaultAsync(x => x.Id == relievingId && x.Student.InstituteId == loggedInUserInstituteId);

            if (relieving == null)
            {
                return(Ok(new StudentRelievingManagementResponse()
                {
                    HasError = true, Message = "Student not found", ErrorType = StudentRelievingManagementResponseType.StudentId
                }));
            }
            else
            {
                relieving.StudentRelievingDescription = EnumHelperService.GetDescription(relieving.StudentRelieving);
                return(Ok(relieving));
            }
        }