public ServiceResponseDTO <ApplicantLevelDTO> SaveApplicantLevel(ApplicantLevelDTO dto) { var result = new ServiceResponseDTO <ApplicantLevelDTO>(true, new ApplicantLevelDTO(), new List <string>()); try { var request = _mapper.Map <ApplicantLevel>(dto); ApplicantLevel model; if (dto.Id == 0) { model = _applicantLevelRepo.CreateApplicantLevel(request); } else { model = _applicantLevelRepo.UpdateApplicantLevel(request); } result.ResponseData = _mapper.Map <ApplicantLevelDTO>(model); } catch (Exception ex) { result.Success = false; result.Errors.Add(ex.Message); } return(result); }
/// <summary> /// Adds the project. /// </summary> /// <param name="projectDto">The project dto.</param> /// <returns></returns> public ServiceResponseDTO <ProjectDTO> AddProject(ProjectDTO projectDto) { var result = new ServiceResponseDTO <ProjectDTO>(); try { var projectEntity = Mapper.Map <Project>(projectDto); var valid = _pmRepository.Validate(projectEntity); projectEntity.DateCreated = DateTime.Now; projectEntity.DateUpdated = DateTime.Now; result.ResponseData = valid ? Mapper.Map <ProjectDTO>(_pmRepository.AddProject(projectEntity)) : null; result.Success = true; } catch (Exception ex) { result.Errors = new List <string> { ex.Message }; result.Success = false; } return(result); }
public ServiceResponseDTO <ApplicantLevelDTO> GetApplicantLevel(int id) { var result = new ServiceResponseDTO <ApplicantLevelDTO>(true, new ApplicantLevelDTO(), new List <string>()); if (id == 0) { result.Errors.Add("Id was not set."); result.Success = false; return(result); } try { var request = _applicantLevelRepo.GetApplicantLevelById(id); if (request != null) { result.ResponseData = _mapper.Map <ApplicantLevelDTO>(request); } } catch (Exception ex) { result.Errors.Add(ex.Message); result.Success = false; } return(result); }
public ServiceResponseDTO <ApplicantLevelDTO> GetApplicantLevel(string name) { var result = new ServiceResponseDTO <ApplicantLevelDTO>(true, new ApplicantLevelDTO(), new List <string>()); if (name.Trim().Length == 0) { result.Errors.Add("Name is empty."); result.Success = false; return(result); } try { var request = _applicantLevelRepo.GetApplicantLevelByName(name); if (request != null) { result.ResponseData = _mapper.Map <ApplicantLevelDTO>(request); } } catch (Exception ex) { result.Errors.Add(ex.Message); result.Success = false; } return(result); }
public ServiceResponseDTO <List <TechnologyDetailDTO> > GetTechnologyDetailList() { ServiceResponseDTO <List <TechnologyDetailDTO> > result = new ServiceResponseDTO <List <TechnologyDetailDTO> >(true, new List <TechnologyDetailDTO>(), new List <string>()); try { var reply = _techDetailContext.GetTechnologyDetailList(); if (reply != null) { var list = new List <TechnologyDetailDTO>(); foreach (var item in reply) { list.Add(_mapper.Map <TechnologyDetailDTO>(item)); } result.ResponseData = list; } } catch (Exception ex) { result.Errors.Add(ex.Message); result.Success = false; } return(result); }
public ServiceResponseDTO <List <ApplicantLevelDTO> > GetApplicantLevelList() { var result = new ServiceResponseDTO <List <ApplicantLevelDTO> >(true, new List <ApplicantLevelDTO>(), new List <string>()); try { var reply = _applicantLevelRepo.GetApplicantLevelList(); if (reply != null) { var list = new List <ApplicantLevelDTO>(); foreach (var item in reply) { list.Add(_mapper.Map <ApplicantLevelDTO>(item)); } result.ResponseData = list; } } catch (Exception ex) { result.Errors.Add(ex.Message); result.Success = false; } return(result); }
public ServiceResponseDTO <TechnologyDetailDTO> GetTechnologyDetail(int id) { ServiceResponseDTO <TechnologyDetailDTO> result = new ServiceResponseDTO <TechnologyDetailDTO>(true, new TechnologyDetailDTO(), new List <string>()); if (id == 0) { result.Errors.Add("Id was not set."); result.Success = false; return(result); } try { var request = _techDetailContext.GetTechnologyDetailById(id); if (request != null) { result.ResponseData = _mapper.Map <TechnologyDetailDTO>(request); } } catch (Exception ex) { result.Errors.Add(ex.Message); result.Success = false; } return(result); }
public ServiceResponseDTO <TechnologyDetailDTO> GetTechnologyDetail(string name) { ServiceResponseDTO <TechnologyDetailDTO> result = new ServiceResponseDTO <TechnologyDetailDTO>(true, new TechnologyDetailDTO(), new List <string>()); if (name.Trim().Length == 0) { result.Errors.Add("Name is empty."); result.Success = false; return(result); } try { var request = _techDetailContext.GetTechnologyDetailByName(name); if (request != null) { result.ResponseData = _mapper.Map <TechnologyDetailDTO>(request); } } catch (Exception ex) { result.Errors.Add(ex.Message); result.Success = false; } return(result); }
public ServiceResponseDTO <PrimarySkillDTO> Put([FromBody] PrimarySkillDTO value) { var response = new ServiceResponseDTO <PrimarySkillDTO>(); try { if (value.Id != 0) { response = _primarySkillService.UpdatePrimarySkill(value); } else { response.Errors.Add("Id not present."); } } catch (Exception ex) { response.Errors = new List <string>() { ex.Message }; response.Success = false; } return(response); }
/// <summary> /// Add Applicant /// </summary> /// <param name="applicant"></param> /// <returns></returns> public ServiceResponseDTO <ApplicantsDTO> AddApplicant(ApplicantsDTO applicant) { var result = new ServiceResponseDTO <ApplicantsDTO>(); try { var _applicant = Mapper.Map <Applicant>(applicant); var valid = _applicantsRepository.Validate(_applicant); if (valid) { applicant = Mapper.Map <ApplicantsDTO>(_applicantsRepository.AddApplicant(_applicant)); applicant.Id = _applicant.Id; applicant.StatusType = Enum.GetName(typeof(ApplicantStatusType), applicant.Status); result.ResponseData = applicant; } else { result.ResponseData = null; } result.Success = true; } catch (Exception ex) { result.Errors = new List <string>() { ex.Message }; result.Success = false; } return(result); }
public ServiceResponseDTO <TechnologyDetailDTO> SaveTechnologyDetail(TechnologyDetailDTO dto) { ServiceResponseDTO <TechnologyDetailDTO> result = new ServiceResponseDTO <TechnologyDetailDTO>(true, new TechnologyDetailDTO(), new List <string>()); try { var request = _mapper.Map <Technology>(dto); Technology model; if (dto.Id == 0) { model = _techDetailContext.CreateTechnologyDetail(request); } else { model = _techDetailContext.UpdateTechnologyDetail(request); } result.ResponseData = _mapper.Map <TechnologyDetailDTO>(model); } catch (Exception ex) { result.Success = false; result.Errors.Add(ex.Message); } return(result); }
/// <summary> /// </summary> /// <param name="newRole"></param> /// <returns></returns> public ServiceResponseDTO <RoleDTO> AddRole(RoleDTO newRole) { var result = new ServiceResponseDTO <RoleDTO>(); try { var valid = _roleRepository.Validate(Mapper.Map <Role>(newRole)); if (valid) { newRole.IsActive = true; result.ResponseData = _roleRepository.AddRole(newRole); } else { result.ResponseData = null; } result.Success = true; } catch (Exception ex) { result.Errors = new List <string>() { ex.Message }; result.Success = false; } return(result); }
/// <summary> /// /// </summary> /// <returns></returns> public ServiceResponseDTO <IEnumerable <SelectionItemDTO> > Regions() { var dto = new List <DTO.SelectionItemDTO>(); var response = new ServiceResponseDTO <IEnumerable <SelectionItemDTO> >(); try { var result = _lookupRepository.Regions; if (response != null && result.Count > 0) { result.ForEach(a => dto.Add(new DTO.SelectionItemDTO() { Id = a.Id, Name = a.Name })); response.Success = true; response.ResponseData = dto; } else { throw new Exception("No application levels found."); } } catch (Exception ex) { response.Success = false; response.Errors.Add(ex.Message); } return(response); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public ServiceResponseDTO <CurrentUserDTO> Authenticate(string username, string password) { var response = new ServiceResponseDTO <CurrentUserDTO>(); response.Success = false; response.ResponseData = new DTO.CurrentUserDTO(); try { var user = _userContext.GetByEmail(username); if (user == null) { throw new Exception("User not found."); } //bypass admin password hashing for now if (username == "*****@*****.**") { response.Success = password == "admadm12345"; if (!response.Success) { throw new Exception("Invalid password."); } } else { if (!user.IsActive) { throw new Exception("User account is deactivated."); } byte[] passwordHash = KeyDerivation.Pbkdf2(password, user.Salt, KeyDerivationPrf.HMACSHA256, 1000, 256 / 8); if (!user.PasswordHash.SequenceEqual(passwordHash)) { throw new Exception("Invalid password."); } } var model = _mapper.Map <CurrentUserDTO>(user); model.Permissions = new List <string>(); foreach (var permission in user.Role.RolePermission) { model.Permissions.Add(permission.Permission.Name); } response.ResponseData = model; response.Success = true; return(response); } catch (Exception ex) { response.Errors.Add(ex.Message); return(response); } }
public ServiceResponseDTO <List <SampleDTO> > getList() { var response = new ServiceResponseDTO <List <SampleDTO> >(); response.Success = true; response.ResponseData = new List <SampleDTO>(); response.ResponseData.Add(new SampleDTO(1, "DatePicker", "inprogress")); response.ResponseData.Add(new SampleDTO(2, "List", "samples")); return(response); }
public ServiceResponseDTO <ApplicantLevelDTO> Update([FromBody] ApplicantLevelDTO dto) { var response = new ServiceResponseDTO <ApplicantLevelDTO>(false, new ApplicantLevelDTO(), new List <string>()); try { response = _applicantLevelSvc.SaveApplicantLevel(dto); } catch (Exception ex) { response.Errors.Add(ex.Message); } return(response); }
public ServiceResponseDTO <List <ApplicantLevelDTO> > GetList() { var response = new ServiceResponseDTO <List <ApplicantLevelDTO> >(false, new List <ApplicantLevelDTO>(), new List <string>()); try { response = _applicantLevelSvc.GetApplicantLevelList(); } catch (Exception ex) { response.Errors.Add(ex.Message); } return(response); }
public ServiceResponseDTO <ApplicantLevelDTO> CheckIfExists(string name) { var response = new ServiceResponseDTO <ApplicantLevelDTO>(false, new ApplicantLevelDTO(), new List <string>()); try { response = _applicantLevelSvc.GetApplicantLevel(name); } catch (Exception ex) { response.Errors.Add(ex.Message); } return(response); }
public ServiceResponseDTO <UserDTO> Post([FromBody] UserDTO newUser) { var serviceResponse = new ServiceResponseDTO <UserDTO>(); try { serviceResponse = _userService.AddUser(newUser); } catch (Exception ex) { serviceResponse.Errors.Add(ex.Message); serviceResponse.Success = false; } return(serviceResponse); }
public ServiceResponseDTO <UserDTO> Put([FromBody] UserDTO updatedUser) { var response = new ServiceResponseDTO <UserDTO>(); try { _userService.UpdateUser(updatedUser); } catch (Exception ex) { response.Success = false; } response.Success = true; return(response); }
public ServiceResponseDTO <UserDTO> Get(string email) { var serviceResponse = new ServiceResponseDTO <UserDTO>(); try { serviceResponse = _userService.GetUser(email); } catch (Exception ex) { serviceResponse.Errors.Add(ex.Message); serviceResponse.Success = false; } return(serviceResponse); }
/// <summary> /// Updates the role. /// </summary> /// <param name="role">The role.</param> /// <returns></returns> public ServiceResponseDTO <RoleDTO> UpdateRole(RoleDTO role) { var result = new ServiceResponseDTO <RoleDTO>(); try { var _role = Mapper.Map <Role>(role); var valid = _roleRepository.Validate(_role); if (valid) { _role.RolePermission = role.Permissions.Select(a => new RolePermission() { RoleId = role.Id, PermissionId = a.Id }).ToList(); role = Mapper.Map <RoleDTO>(_roleRepository.UpdateRole(_role)); _roleRepository.UpdateRolePermission(role.Id, _role.RolePermission) .ToList() .ForEach(a => { role.Permissions.Add(Mapper.Map <PermissionDTO>(a)); }); result.ResponseData = role; } else { result.ResponseData = null; } result.Success = true; } catch (Exception ex) { result.Errors = new List <string>() { ex.Message }; result.Success = false; } return(result); }
public ServiceResponseDTO <List <UserNavigationDTO> > GetUserNavigations([FromBody] UserDTO user) { //call this api via url api/user/navigations var serviceResponse = new ServiceResponseDTO <List <UserNavigationDTO> >(); try { serviceResponse = _userService.GetUserNavigationAccess(user); } catch (Exception ex) { serviceResponse.Errors.Add(ex.Message); serviceResponse.Success = false; } return(serviceResponse); }
public ServiceResponseDTO <UserDTO> GetByUserId(int userId) { var serviceResponse = new ServiceResponseDTO <UserDTO>(); try { serviceResponse = _userService.GetUser(userId); serviceResponse.Success = true; } catch (Exception ex) { serviceResponse.Errors.Add(ex.Message); serviceResponse.Success = false; } return(serviceResponse); }
public ServiceResponseDTO <IEnumerable <TaggedApplicantDTO> > GetTaggedReferencePool(int appId) { var result = new ServiceResponseDTO <IEnumerable <TaggedApplicantDTO> >(); try { result.ResponseData = _repository.GetTaggedRefNumbers(appId).Select(row => Mapper.Map <TaggedApplicantDTO>(row)); result.Success = true; } catch (Exception ex) { result.Errors = new List <string>() { ex.Message }; result.Success = false; } return(result); }
public ServiceResponseDTO <CurrentUserDTO> Put([FromBody] UpdatePasswordDTO updatePwdDto) { var response = new ServiceResponseDTO <CurrentUserDTO>(); try { response = _authenticationSvc.Authenticate(updatePwdDto.UserName, updatePwdDto.CurrentPassword); if (response.Success) { _userService.UpdateUserPassword(updatePwdDto.UserName, updatePwdDto.NewPassword); } } catch (Exception e) { response.Success = false; response.Errors.Add(e.Message); } return(response); }
public ServiceResponseDTO <ApplicantLevelDTO> ToggleActive(int id) { var result = new ServiceResponseDTO <ApplicantLevelDTO>(); try { result.ResponseData = _applicantLevelRepo.ToggleActive(id); result.Success = true; } catch (Exception ex) { result.Errors = new List <string> { ex.Message }; result.Success = false; } return(result); }
/// <summary> /// Toggles the active. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public ServiceResponseDTO <ProjectDTO> ToggleActive(int id) { var result = new ServiceResponseDTO <ProjectDTO>(); try { result.ResponseData = Mapper.Map <ProjectDTO>(_pmRepository.ToggleActive(id)); result.Success = true; } catch (Exception ex) { result.Errors = new List <string> { ex.Message }; result.Success = false; } return(result); }
/// <summary> /// /// </summary> /// <returns></returns> public ServiceResponseDTO <IEnumerable <HiringRequestDTO> > GetHriringRequests(int skillId = 0, int projectId = 0, int statusID = 0) { var result = new ServiceResponseDTO <IEnumerable <HiringRequestDTO> >(); try { result.ResponseData = _repository.GetHriringRequests(skillId, projectId, statusID).Select(hr => Mapper.Map <HiringRequestDTO>(hr)); result.Success = true; } catch (Exception ex) { result.Errors = new List <string>() { ex.Message }; result.Success = false; } return(result); }
public ServiceResponseDTO <ReferenceNumberReasonDTO> UpdateReferenceNumberStatus(ReferenceNumberReasonDTO dto) { ServiceResponseDTO <ReferenceNumberReasonDTO> result = new ServiceResponseDTO <ReferenceNumberReasonDTO>() { Success = true, ResponseData = new ReferenceNumberReasonDTO(), Errors = new List <string>() }; try { result.Success = _repository.UpdateReferenceNumberStatus(dto.RefNumberId, dto.Reason, dto.NewStatus); result.ResponseData = dto; } catch (Exception) { throw; } return(result); }