Beispiel #1
0
        public async Task <AccessLevelDefinition> Add(AccessLevelDefinition staff)
        {
            _db.AccessLevelDefinition.Add(staff);
            await _db.SaveChangesAsync();

            return(staff);
        }
Beispiel #2
0
        public async Task <AttendanceLetters> SaveLetter(AttendanceLetters letter)
        {
            _db.AttendanceLetters.Add(letter);
            await _db.SaveChangesAsync();

            return(letter);
        }
        public async Task <StaffEducationOrganizationAssignmentAssociation> Add(StaffEducationOrganizationAssignmentAssociation staff)
        {
            _db.StaffEducationOrganizationAssignmentAssociation.Add(staff);
            await _db.SaveChangesAsync();

            if (staff.StaffClassificationDescriptorId == 40789)
            {
                var people = await _db.People.FirstOrDefaultAsync(x => x.Usi == staff.StaffUSI);

                if (people != null)
                {
                    var accessLevel = await _db.AccessLevelDefinition.FirstOrDefaultAsync(m => m.Email == people.ElectronicMailAddress);

                    if (accessLevel == null)
                    {
                        AccessLevelDefinition newAccess = new AccessLevelDefinition()
                        {
                            Email = people.ElectronicMailAddress
                        };
                        _db.AccessLevelDefinition.Add(newAccess);
                        await _db.SaveChangesAsync();
                    }
                }
            }

            return(staff);
        }
        public async Task <List <StudentExtraHours> > CreateStudentExtraHourBulk(List <StudentExtraHours> studentExtraHours)
        {
            await _db.StudentExtraHours.AddRangeAsync(studentExtraHours);

            await _db.SaveChangesAsync();

            return(studentExtraHours);
        }
Beispiel #5
0
        public async Task <AccessToSystem> CreateAccessToSystem(AccessToSystem data)
        {
            AccessToSystem access = new AccessToSystem();

            access = await _db.AccessToSystem.FirstOrDefaultAsync(m => m.LastLogin.Date == data.LastLogin.Date && m.LastLogin.Hour == data.LastLogin.Hour && m.LastLogin.Minute == data.LastLogin.Minute && m.Email == data.Email);

            if (access == null)
            {
                using (var transaction = _db.Database.BeginTransaction())
                {
                    if (data.Id != 0)
                    {
                        await _db.Database.ExecuteSqlRawAsync("SET IDENTITY_INSERT [dbo].[AccessToSystem] On");
                    }

                    _db.AccessToSystem.Add(data);
                    await _db.SaveChangesAsync();

                    if (data.Id != 0)
                    {
                        await _db.Database.ExecuteSqlRawAsync("SET IDENTITY_INSERT [dbo].[AccessToSystem] Off");
                    }

                    await transaction.CommitAsync();
                }
            }
            return(data);
        }