Exemple #1
0
        public async Task <bool> Add([FromBody] InstitutionEmployee institutionEmployee)
        {
            string token = this.TokenFromHeader(Request);

            institutionEmployee.InstitutionId = AuthenticationService.GetInstitutionId(token);
            return(await institutionEmployeeService.Add(institutionEmployee));
        }
Exemple #2
0
        private InstitutionEmployee AlreadyWorked(InstitutionEmployee institutionEmployee)
        {
            var currentInstitutionEmployee = this.repository.Get <InstitutionEmployee>(true,
                                                                                       x => x.InstitutionId == institutionEmployee.InstitutionId &&
                                                                                       x.UserId == institutionEmployee.UserId && x.Role == institutionEmployee.Role);

            return(currentInstitutionEmployee);
        }
Exemple #3
0
        public async Task <bool> Dismiss([FromBody] InstitutionEmployee institutionEmployee)
        {
            string token  = this.TokenFromHeader(Request);
            int    userId = AuthenticationService.GetUserId(token);

            if (institutionEmployee.UserId == userId)
            {
                return(false);
            }
            return(await institutionEmployeeService.Dismiss(institutionEmployee));
        }
Exemple #4
0
        public async Task <bool> Delete(InstitutionEmployee institutionEmployee)
        {
            var currentInstitutionEmployee = await this.repository.GetAsync <InstitutionEmployee>(true, x => x.Id == institutionEmployee.Id);

            if (currentInstitutionEmployee == null)
            {
                throw new Exception("InstitutionEmployee not found.");
            }
            await this.repository.DeleteAsync <InstitutionEmployee>(currentInstitutionEmployee);

            return(true);
        }
Exemple #5
0
        public async Task <bool> Add(InstitutionEmployee institutionEmployee)
        {
            if (AlreadyWorked(institutionEmployee) != null)
            {
                await Reinstate(institutionEmployee);
            }
            else
            {
                institutionEmployee.IsWorking = true;
                await this.repository.AddAsync <InstitutionEmployee>(institutionEmployee);
            }

            return(true);
        }
Exemple #6
0
        public async Task <bool> Reinstate(InstitutionEmployee institutionEmployee)
        {
            var currentInstitutionEmployee = await this.repository.GetAsync <InstitutionEmployee>(true,
                                                                                                  x => x.InstitutionId == institutionEmployee.InstitutionId &&
                                                                                                  x.UserId == institutionEmployee.UserId && x.Role == institutionEmployee.Role);

            if (currentInstitutionEmployee == null)
            {
                throw new Exception("InstitutionEmployee not found.");
            }

            currentInstitutionEmployee.IsWorking = true;
            await this.repository.UpdateAsync <InstitutionEmployee>(currentInstitutionEmployee);

            return(true);
        }
Exemple #7
0
 public async Task <bool> Reinstate([FromBody] InstitutionEmployee institutionEmployee)
 {
     return(await institutionEmployeeService.Reinstate(institutionEmployee));
 }