Esempio n. 1
0
        public async Task <SingleResponse <Administrator> > GetAdmByEmail(string email, string passcode)
        {
            try
            {
                passcode = EncryptPassword(passcode);

                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Administrator administrator = await dataBase.Administrators.FirstOrDefaultAsync(c => c.Email == email && c.Passcode == passcode);

                    if (administrator == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Administrator>());
                    }
                    //Precisa de cookies
                    //SystemParameters.EmployeeName = response.Data.Name;
                    //SystemParameters.EmployeeADM = response.Data.IsAdm;
                    return(ResponseMessage.CreateSingleSuccessResponse <Administrator>(administrator));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Administrator> administrator = (SingleResponse <Administrator>)ResponseMessage.CreateErrorResponse(ex);
                return(administrator);
            }
        }
Esempio n. 2
0
        public async Task <SingleResponse <Teacher> > ChangeStatus(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Teacher teacher = dataBase.Teachers.Find(id);
                    if (teacher.Active == false)
                    {
                        teacher.Active = true;
                    }
                    else
                    {
                        teacher.Active = false;
                    }
                    await dataBase.SaveChangesAsync();

                    return(ResponseMessage.CreateSingleSuccessResponse <Teacher>(teacher));
                }
            }
            catch (Exception ex)
            {
                return(ResponseMessage.CreateNotFoundData <Teacher>());
            }
        }
Esempio n. 3
0
        public async Task <SingleResponse <Subject> > ChangeStatus(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Subject subject = dataBase.Subjects.Find(id);
                    if (subject.Active == false)
                    {
                        subject.Active = true;
                    }
                    else
                    {
                        subject.Active = false;
                    }
                    await dataBase.SaveChangesAsync();

                    return(ResponseMessage.CreateSingleSuccessResponse <Subject>(subject));
                }
            }
            catch (Exception ex)
            {
                ResponseMessage.CreateErrorResponse(ex);
                return(ResponseMessage.CreateNotFoundData <Subject>());
            }
        }
Esempio n. 4
0
        public async Task <SingleResponse <Administrator> > ChangeStatus(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Administrator administrator = dataBase.Administrators.Find(id);
                    if (administrator.Active == false)
                    {
                        administrator.Active = true;
                    }
                    else
                    {
                        administrator.Active = false;
                    }
                    await dataBase.SaveChangesAsync();

                    return(ResponseMessage.CreateSingleSuccessResponse <Administrator>(administrator));
                }
            }
            catch (Exception ex)
            {
                ResponseMessage.CreateErrorResponse(ex);
                return(ResponseMessage.CreateNotFoundData <Administrator>());
            }
        }
Esempio n. 5
0
        public async Task <SingleResponse <Teacher> > GetByID(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Teacher teacher = await dataBase.Teachers.FirstOrDefaultAsync(p => p.ID == id);

                    if (teacher == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Teacher>());
                    }
                    return(ResponseMessage.CreateSingleSuccessResponse <Teacher>(teacher));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Teacher> teacher = (SingleResponse <Teacher>)ResponseMessage.CreateErrorResponse(ex);
                return(teacher);
            }
        }
Esempio n. 6
0
        public async Task <SingleResponse <Subject> > GetByID(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Subject subject = await dataBase.Subjects.FirstOrDefaultAsync(p => p.ID == id);

                    if (subject == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Subject>());
                    }
                    return(ResponseMessage.CreateSingleSuccessResponse <Subject>(subject));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Subject> subject = (SingleResponse <Subject>)ResponseMessage.CreateErrorResponse(ex);
                return(subject);
            }
        }
Esempio n. 7
0
        public async Task <SingleResponse <Administrator> > GetByID(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Administrator administrator = await dataBase.Administrators.FirstOrDefaultAsync(p => p.Id == id);

                    if (administrator == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Administrator>());
                    }
                    return(ResponseMessage.CreateSingleSuccessResponse <Administrator>(administrator));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Administrator> administrator = (SingleResponse <Administrator>)ResponseMessage.CreateErrorResponse(ex);
                return(administrator);
            }
        }
Esempio n. 8
0
        public async Task <SingleResponse <Class> > GetByID(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Class clasS = await dataBase.Classes.FirstOrDefaultAsync(p => p.ID == id);

                    if (clasS == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Class>());
                    }
                    return(ResponseMessage.CreateSingleSuccessResponse <Class>(clasS));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Class> clasS = (SingleResponse <Class>)ResponseMessage.CreateErrorResponse(ex);
                return(clasS);
            }
        }
Esempio n. 9
0
        public async Task <SingleResponse <Student> > IsUniqueRegister(string register)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Student student = await dataBase.Students.FirstOrDefaultAsync(p => p.Register == register);

                    if (student == null)
                    {
                        return(ResponseMessage.CreateSingleSuccessResponse <Student>(student));
                    }
                    return(ResponseMessage.CreateNotFoundData <Student>());
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Student> student = (SingleResponse <Student>)ResponseMessage.CreateErrorResponse(ex);
                return(student);
            }
        }
Esempio n. 10
0
        public async Task <SingleResponse <Lesson> > GetByID(int id)
        {
            try
            {
                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Lesson lesson = await dataBase.Lessons.FirstOrDefaultAsync(p => p.ID == id);

                    if (lesson == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Lesson>());
                    }
                    return(ResponseMessage.CreateSingleSuccessResponse <Lesson>(lesson));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Lesson> lesson = (SingleResponse <Lesson>)ResponseMessage.CreateErrorResponse(ex);
                return(lesson);
            }
        }
Esempio n. 11
0
        public async Task <SingleResponse <Teacher> > GetTeacherByEmail(string email, string passcode)
        {
            try
            {
                passcode = passcode.EncryptPassword();

                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Teacher teacher = await dataBase.Teachers.FirstOrDefaultAsync(c => c.Email == email && c.Passcode == passcode);

                    if (teacher == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Teacher>());
                    }
                    //Precisa de cookies
                    return(ResponseMessage.CreateSingleSuccessResponse <Teacher>(teacher));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Teacher> teacher = (SingleResponse <Teacher>)ResponseMessage.CreateErrorResponse(ex);
                return(teacher);
            }
        }
Esempio n. 12
0
        public async Task <SingleResponse <Student> > GetStudentByRegister(string register, string passcode)
        {
            try
            {
                passcode = passcode.EncryptPassword();

                using (BiometricPresenceDB dataBase = new BiometricPresenceDB())
                {
                    Student student = await dataBase.Students.FirstOrDefaultAsync(c => c.Register == register && c.Passcode == passcode);

                    if (student == null)
                    {
                        return(ResponseMessage.CreateNotFoundData <Student>());
                    }
                    //Precisa de cookies
                    return(ResponseMessage.CreateSingleSuccessResponse <Student>(student));
                }
            }
            catch (Exception ex)
            {
                SingleResponse <Student> student = (SingleResponse <Student>)ResponseMessage.CreateErrorResponse(ex);
                return(student);
            }
        }