public async Task <bool> Edit(JobOffer item) { var offer = await _jobOfferRepo.GetById(item.JobOfferId); offer.JobCategory = await _jobCategoryRepo.GetById(item.JobCategoryId); offer.JobType = await _jobTypeRepo.GetById(item.JobTypeId); offer.PostalCode = item.PostalCode; offer.Title = item.Title; offer.Description = item.Description; offer.Wage = item.Wage; offer.LastEdit = DateTime.Now; try { _jobOfferRepo.Update(offer); await _unitOfWork.Save(); } catch (DbUpdateConcurrencyException) { return(false); } return(true); }
public async Task <IActionResult> IndexAsync() { List <ClientJobViewModel> model = new List <ClientJobViewModel>(); if (!_signInManager.IsSignedIn(User)) { return(Redirect("~/Account/LoginClient")); } else { System.Security.Claims.ClaimsPrincipal currentUser = User; var isClient = currentUser.IsInRole("client") || currentUser.IsInRole("client-editor"); if (isClient) { var user = await _userManager.GetUserAsync(User); var client = _clientRepository.GetClientByUserId(user.Id); IEnumerable <Job> jobs = _jobsRepository.Find(x => x.ClientId == client.Id); foreach (var job in jobs) { ClientJobViewModel clientjobmodel = new ClientJobViewModel(); var jobcategory = _jobCategoryRepository.GetById(job.JobCategoryId); clientjobmodel.JobId = job.Id; clientjobmodel.JobTitle = jobcategory.CategoryName_JP; clientjobmodel.JapaneseLevel = job.JapaneseLevel_Text; clientjobmodel.Workinghour = job.Workinghour; clientjobmodel.WorkingDaysPerWeek = job.WorkingdaysPerweek; //clientjobmodel.ContractType = job.WorkinghourPerday; clientjobmodel.Address = job.WorkLocationAddress; clientjobmodel.ProvinceName = job.provinceName; clientjobmodel.Salary = job.Salary_Hourly; clientjobmodel.PostDate = job.PostDate; clientjobmodel.Status = job.Status; var jobapplied = _jobApplyRepository.GetAppliedCount(job.Id); clientjobmodel.CandidateApplied = jobapplied.Count; model.Add(clientjobmodel); } return(View(model)); } } return(Redirect("~/Account/LoginClient")); }
public async Task <ActionResult <JobCategoryDto> > GetById(int id) { var jobCategory = await _repository.GetById(id); if (jobCategory == null) { return(NotFound(JobCategoryNotFound)); } return(Ok(jobCategory)); }
public async Task <dynamic> AllJobsBakAsync(DataTableAjaxPostModel model) { // action inside a standard controller int filteredResultsCount; int totalResultsCount; var searchBy = (model.search != null) ? model.search.value : null; var take = model.length; var skip = model.start; string sortBy = ""; string sortDir = ""; if (model.order != null) { // in this example we just default sort on the 1st column sortBy = model.columns[model.order[0].column].data; sortDir = model.order[0].dir.ToLower(); } var jobs = await _jobsRepository.GetAllAsyn(); //convert to anonymous type object list as inummerable var newObject = jobs.Select(x => new { JobID = x.Id, JobTitle = _jobCategoryRepository.GetById(x.JobCategoryId).CategoryName_JP ?? "", CompanyName = _clientRepository.GetById(x.ClientId).CompanyName ?? "", ProvinceName = x.provinceName ?? "", x.PostDate }); //searching totalResultsCount = newObject.Count(); if (!string.IsNullOrWhiteSpace(searchBy)) { searchBy = searchBy.ToLower(); newObject = newObject.Where(x => x.JobID.ToString().Contains(searchBy) || x.JobTitle.ToLower().Contains(searchBy) || x.CompanyName.ToLower().Contains(searchBy) || x.PostDate.ToString().ToLower().Contains(searchBy) || x.ProvinceName.ToLower().Contains(searchBy)); // if we have an empty search then just order the results by Id ascending sortBy = "jobID"; sortDir = "asc"; } filteredResultsCount = newObject.Count(); newObject = newObject .AsQueryable() .OrderBy(sortBy + " " + sortDir) //sorting .Skip(model.start) .Take(model.length) .ToList(); var secondObj = new { model.draw, recordsTotal = totalResultsCount, recordsFiltered = filteredResultsCount, data = newObject }; return(secondObj); }
public IActionResult GetById(int id) { return(Ok(_jobCategoryRepository.GetById(id))); }
public async Task <JobCategory> GetCategoryById(string id) { return(await _repo.GetById(id)); }