public async Task <bool> Add([FromBody] InstitutionEmployee institutionEmployee) { string token = this.TokenFromHeader(Request); institutionEmployee.InstitutionId = AuthenticationService.GetInstitutionId(token); return(await institutionEmployeeService.Add(institutionEmployee)); }
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); }
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)); }
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); }
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); }
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); }
public async Task <bool> Reinstate([FromBody] InstitutionEmployee institutionEmployee) { return(await institutionEmployeeService.Reinstate(institutionEmployee)); }