public IActionResult SaveBiographicResponse([FromBody] BiographicResponse biographicResponse) { if (biographicResponse == null) { return(BadRequest("Error, Make sure your selection is valid")); } try { Project project = _context.Projects.FirstOrDefault(id => id.ProjectIdentifier.ToString() == biographicResponse.ProjectIdentifier); Employee employee = _context.Employees.FirstOrDefault(id => (id.Identifier.ToString() == biographicResponse.EmployeeIdentifier)); EmployeeBiographic response = _context.EmployeeBiographics.FirstOrDefault(id => (id.EmployeeId == employee.EmployeeId) && (id.BiographicId == biographicResponse.BiographicId)); response.IsBiographicDetail = true; response.BiographicDetailId = biographicResponse.BiographicDetailId; _context.EmployeeBiographics.Update(response); _context.SaveChanges(); return(Ok(response)); } catch (Exception Ex) { return(BadRequest("Something bad happened! " + Ex.Message)); } }
public IActionResult GetEmployeeSurveyConsent([FromBody] EmployeeSurvey model) { if (model == null) { return(BadRequest("Error, Contact your Manager/ Administrator!")); } try { Employee employee = _context.Employees.FirstOrDefault(id => id.Identifier.ToString() == model.EmployeeIdentifier); Project project = _context.Projects.FirstOrDefault(id => id.ProjectIdentifier.ToString() == model.ProjectIdentifier); ProjectParticipant projectParticipant = _context.ProjectParticipants.FirstOrDefault(id => (id.ParticipantId == employee.EmployeeId) && (id.ProjectId == project.ProjectId)); projectParticipant.IsAcknowledged = true; _context.ProjectParticipants.Update(projectParticipant); _context.SaveChanges(); return(Ok()); } catch (Exception Ex) { return(BadRequest("Something bad happened! " + Ex.Message)); } }
public IActionResult GetEmployeeSurvey([FromBody] EmployeeSurvey model) { if (model == null) { return(BadRequest("Error, Make sure form is complete!")); } try { Employee employee = _context.Employees.FirstOrDefault(id => id.Identifier.ToString() == model.EmployeeIdentifier); Project project = _context.Projects.FirstOrDefault(id => id.ProjectIdentifier.ToString() == model.ProjectIdentifier); ProjectParticipant projectParticipant = _context.ProjectParticipants.FirstOrDefault(id => (id.ParticipantId == employee.EmployeeId) && (id.ProjectId == project.ProjectId)); if ((employee != null) && (project != null)) { var employeeSurvey = new { Name = employee.Name, Surname = employee.Surname, Email = employee.Email, Organization = _context.AssetNodes.FirstOrDefault(id => id.AssetNodeId == employee.AssetNodeId).Name, Root = _context.AssetNodes.FirstOrDefault(id => id.AssetNodeId == _context.AssetNodes.FirstOrDefault(id => id.AssetNodeId == employee.AssetNodeId).RootAssetNodeId).Name, ProjectName = project.Name, ProjectStartDate = project.StartDate.ToString("dd MMM yyyy"), ProjectEndDate = project.EndDate.ToString("dd MMM yyyy"), ProjectType = _context.Surveys.FirstOrDefault(id => id.SurveyId == project.SurveyId).Name, IsParticipated = projectParticipant.IsParticipated, IsAcknowleged = projectParticipant.IsAcknowledged }; return(Ok(employeeSurvey)); } return(Ok()); } catch (Exception Ex) { return(BadRequest("Something bad happened. " + Ex.Message)); } }