コード例 #1
0
ファイル: HealthService.cs プロジェクト: rikiapter/netcore
        public async Task <ISingleResponse <MainScreenHealthResponse> > GetMainScreenHealthAsync(int siteId)
        {
            var response = new SingleResponse <MainScreenHealthResponse>();
            // Get list by Employee by Id
            //var query = DbContext.GetNumberEmployeesOnSiteAsync(siteId);
            DateTime date = DateTime.Now.Date;//today

            response.Model = new MainScreenHealthResponse();

            var ListEmployees = await DbContext.GetNumberEmployeesAsync(siteId).ToListAsync();

            response.Model.NumberEmployees       = ListEmployees.Count();
            response.Model.NumberEmployeesOnSite = await DbContext.GetNumberEmployeesOnSiteAsync(siteId, date).GroupBy(x => x.EmployeeId).CountAsync();

            response.Model.EmployeesWithHotBody = await DbContext.GetAlertsAsync(siteId, 2, 6).CountAsync();

            response.Model.NumberVisitors = await DbContext.GetHealthDeclarationAsync(siteId).CountAsync();


            //עובדים באתר
            var ListEmployeesOnSite = await DbContext.GetNumberEmployeesOnSiteAsync(siteId, date).ToListAsync();

            //עובדים שנתנו הצהרת בריאות
            var ListHealthDeclarationAsync = await DbContext.GetHealthDeclarationAsync(siteId, 2).ToListAsync();

            //עובדים נמצאים באתר עם הצהרת בריאות
            var resultWithHealthDeclarationOnSite = from e in ListEmployeesOnSite
                                                    join h in ListHealthDeclarationAsync
                                                    on e.EmployeeId equals h.EntityId
                                                    select new { h.EntityId };

            response.Model.WithoutHealthDeclarationOnSite = ListEmployeesOnSite.Count() - resultWithHealthDeclarationOnSite.Count();


            //עובדים  עם הצהרת בריאות
            var resultWithHealthDeclaration = from e in ListEmployees
                                              join h in ListHealthDeclarationAsync
                                              on e.EmployeeId equals h.EntityId
                                              select new { h.EntityId };


            //עובדים ללא הצהרת בריאות
            response.Model.WithoutHealthDeclaration = response.Model.NumberEmployees - resultWithHealthDeclaration.Count();


            //if (response.Model.NumberEmployeesOnSite != 0)
            //    response.Model.PresentEmployees = response.Model.NumberEmployees / response.Model.NumberEmployeesOnSite * 100;

            if (ListEmployees.Count() != 0)
            {
                response.Model.PresentEmployees = resultWithHealthDeclaration.Count() / ListEmployees.Count() * 100;
            }

            response.SetMessageGetById(nameof(MainScreenHealthResponse), siteId);
            return(response);
        }
コード例 #2
0
        public async Task <SingleResponse <PhoneMail> > GetPhoneMailAsync(int EntityTypeId, int EntityId)
        {
            var response = new SingleResponse <PhoneMail>();

            // Get the Employee by Id
            response.Model = await DbContext.GetPhoneMailAsync(new PhoneMail { EntityTypeId = EntityTypeId, EntityId = EntityId });

            response.SetMessageGetById(nameof(GetAddressAsync), EntityTypeId);
            return(response);
        }
コード例 #3
0
        public async Task <SingleResponse <Docs> > GetDocsAsync(int EntityTypeId, int EntityId, int documentType)
        {
            var response = new SingleResponse <Docs>();
            // Get the Employee by Id
            var res = await DbContext.GetDocsAsync(new Docs { EntityTypeId = EntityTypeId, EntityId = EntityId, DocumentTypeId = documentType });

            response.Model = res;
            response.SetMessageGetById(nameof(GetAddressAsync), EntityTypeId);
            return(response);
        }
コード例 #4
0
ファイル: AlertService.cs プロジェクト: rikiapter/netcore
        public async Task <SingleResponse <Alerts> > CreateAlertAsync(Alerts Alert)
        {
            var response = new SingleResponse <Alerts>();
            // Get the Employee by Id
            var res = DbContext.Add(Alert);
            await DbContext.SaveChangesAsync();

            response.Model = Alert;
            response.SetMessageGetById(nameof(CreateAlertAsync), Alert.SiteId ?? 0);
            return(response);
        }
コード例 #5
0
ファイル: EmployeeService.cs プロジェクト: rikiapter/netcore
        public async Task <SingleResponse <EmployeeEntry> > GetEmployeeEntryByGuidEntry(string guid)
        {
            var response = new SingleResponse <EmployeeEntry>();

            var query = DbContext.GetEmployeeEntryByGuid(guid);

            response.Model = await query.FirstOrDefaultAsync();

            response.SetMessageGetById(nameof(GetEmployeeByGuidEntry), response.Model.EmployeeId ?? 0);

            return(response);
        }
コード例 #6
0
ファイル: EmployeeService.cs プロジェクト: rikiapter/netcore
        public async Task <SingleResponse <Sites> > GetSiteByGuid(string guid)
        {
            var response = new SingleResponse <Sites>();

            var query = DbContext.GetSitesByGuid(guid);

            response.Model = await query.FirstOrDefaultAsync();

            response.SetMessageGetById(nameof(GetSiteByGuid), response.Model.SiteId);

            return(response);
        }
コード例 #7
0
        public async Task <SingleResponse <OrganizationRequest> > GetOrganizationAsync(int Id)
        {
            var response = new SingleResponse <OrganizationRequest>();

            var query = DbContext.GetOrganizationsAsync(new Organization {
                OrganizationId = Id
            });

            response.Model = await query.FirstOrDefaultAsync();

            response.SetMessageGetById(nameof(GetOrganizationAsync), Id);
            return(response);
        }
コード例 #8
0
ファイル: EmployeeService.cs プロジェクト: rikiapter/netcore
        public async Task <SingleResponse <EmployeeResponse> > GetUserAsync(string userName)
        {
            var response = new SingleResponse <EmployeeResponse>();

            var query = DbContext.GetEmployeeByUserIdAsync(new Users {
                UserName = userName
            });

            response.Model = await query.FirstOrDefaultAsync();

            response.SetMessageGetById(nameof(GetEmployeeByUserIdAsync), response.Model.EmployeeId);
            return(response);
        }
コード例 #9
0
ファイル: EmployeeService.cs プロジェクト: rikiapter/netcore
        public async Task <SingleResponse <EmployeeResponse> > GetEmployeeAsync(int Id)
        {
            var response = new SingleResponse <EmployeeResponse>();

            var query = DbContext.GetEmployeesAsync(new Employee {
                EmployeeId = Id
            });

            response.Model = await query.FirstOrDefaultAsync();

            response.SetMessageGetById(nameof(GetEmployeeAsync), Id);
            response.Model.AgreeOnTheBylaws = true;
            return(response);
        }