public IHttpActionResult NewProjectReHire(JobViewModel model) { bool success = false; var message = ""; long serviceid = 0; var reHireUserId = ""; if (!ModelState.IsValid) { var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Value.Errors }).FirstOrDefault(); message = errors.Errors[0].ErrorMessage; } else { try { var jobDetail = context.Jobs.Where(x => x.ID == model.JobId && x.IsActive == true && x.IsDelete == false).FirstOrDefault(); serviceid = jobDetail.ServiceID; reHireUserId = jobDetail.UserID; success = true; message = "Get List"; } catch (Exception ex) { message = ex.Message; } } return(Ok(new { Success = success, Message = message, ServiceId = serviceid, ReHireUserId = reHireUserId })); }
///<summary> ///Obtiene una lista de tareas ejecutadas a partir de una tarea recurrente ///</summary> ///<param name="recurringJob">nombre de la tarea recurrente</param> public List <JobViewModel> GetJobsOfRecurringJob(string recurringJob) { recurringJob = $"\"{recurringJob}\""; var ids = _context.JobParameter.Where(item => item.Value.Equals(recurringJob)).Select(item => item.JobId).Distinct().ToList(); List <JobViewModel> listJobViewModel = new List <JobViewModel>(); var api = JobStorage.Current.GetMonitoringApi(); foreach (long id in ids) { var jobDetails = api.JobDetails(id.ToString()); string state = ""; if (jobDetails.History.Count > 0) { state = jobDetails.History[0].StateName; } JobViewModel job = new JobViewModel() { Id = id.ToString(), Job = jobDetails.Job.ToString(), State = state }; listJobViewModel.Add(job); } return(listJobViewModel); }
public ActionResult Edit(JobViewModel job) { if (ModelState.IsValid) { var _jobDto = new JobDto { Id = job.Id, Name = job.Name, Description = job.Description, Complexity = job.Complexity }; try { this._jobService.Update(_jobDto); return(RedirectToAction("Index", "Job")); } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); } } else { var _duplicatedModelState = ModelState.Values.SingleOrDefault(ms => ms.Errors.Count > 1 && ms.Errors[0].ErrorMessage == ms.Errors[1].ErrorMessage); if (_duplicatedModelState != null) { _duplicatedModelState.Errors.Remove(_duplicatedModelState.Errors[1]); } } return(View(job)); }
public async Task GetJobDetails_ReturnsJobViewModel() { IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = Substitute.For <IMessengerService>(); ILogger logger = Substitute.For <ILogger>(); JobViewModel jvm = new JobViewModel { CompletionStatus = null }; ApiResponse <JobViewModel> jobApiResponse = new ApiResponse <JobViewModel>(HttpStatusCode.OK, jvm); jobsApiClient .GetJobById(Arg.Any <string>()) .Returns(jobApiResponse); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); string jobId = "3456"; //Act JobViewModel viewModel = await jobManagement.GetJobById(jobId); //Assert viewModel .Should() .Be(jvm); }
public IActionResult NewJob(Job newJob) { AppUser currentUser = GetCurrentUser().Result; if (ModelState.IsValid) { newJob.EngID = currentUser.EngID; newJob.Status = "Incomplete"; repository.SaveJob(newJob); JobViewModel newJobViewModel = new JobViewModel { CurrentJob = newJob, CurrentJobExtension = new JobExtension { JobID = newJob.JobID }, CurrentHydroSpecific = new HydroSpecific(), CurrentGenericFeatures = new GenericFeatures(), CurrentIndicator = new Indicator(), CurrentHoistWayData = new HoistWayData(), CurrentTab = "Extension" }; TempData["message"] = $"Job# {newJobViewModel.CurrentJob.JobNum} has been saved...{newJobViewModel.CurrentJob.JobID}...{currentUser.EngID}"; return(View("NextForm", newJobViewModel)); } else { TempData["message"] = $"There seems to be errors in the form. Please validate....{currentUser.EngID}"; TempData["alert"] = $"alert-danger"; return(View(newJob)); } }
public bool Adding(JobViewModel item) { try { Job x = new Job(); x.Post = item.Post; x.Bonus = item.Bonus; x.Experience = item.Experience; x.Vacancy = item.Vacancy; x.Description = item.Description; x.Active = 1; db.Jobs.Add(x); db.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } }
public IActionResult CreateJob(int id, [FromBody] JobViewModel job) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Customer _customerDb = _customerRepository.GetSingle(id); Job _newJob; if (_customerDb == null) { return(NotFound()); } else { _newJob = new Job { JobType = (JobType)Enum.Parse(typeof(JobType), job.JobType), Date = DateTime.Now.Date, Status = JobStatusType.Active, CustomerId = id }; } _jobRepository.Add(_newJob); _jobRepository.Commit(); job = Mapper.Map <Job, JobViewModel>(_newJob); //check logic - return jobs created from customer To-Do CreatedAtRouteResult result = CreatedAtRoute("GetCustomerJobs", new { controller = "Customers", id }, job); return(result); }
// GET: Jobs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Job job = db.Jobs.Find(id); if (job == null) { return(HttpNotFound()); } JobViewModel jobVM = new JobViewModel() { Id = job.Id, Title = job.Title, EndDay = job.EndDay, Cost = job.Cost, Description = job.Description, Skills = job.Skills.Select(s => s.Id).ToArray() }; //ViewBag.Skills = new MultiSelectList(db.Skills.Select(s => new { Id = s.Id, Name = s.Name }), "Id", "Name"); return(View(jobVM)); }
public ActionResult Work() { var work = new WorkViewModel(MenuType.Work, Request.IsAuthenticated, HttpContext.User); var job1 = new JobViewModel { JobId = 0, Picture = "Work/Inuktun/inuktun-logo.png", Company = "Eddyfi Technologies", Position = "Software Designer" }; var job2 = new JobViewModel { JobId = 1, Picture = "Work/CrystalCam/crystalcam-logo.png", Company = "Crystal Cam Imaging, Inc.", Position = "Cooperative Education Student" }; work.Jobs.Add(job1); work.Jobs.Add(job2); return(View(work)); }
public async Task <IActionResult> GetJobById(string jobId, bool includeChildJobs) { Guard.IsNullOrWhiteSpace(jobId, nameof(jobId)); Job job = await _jobsRepositoryPolicy.ExecuteAsync(() => _jobRepository.GetJobById(jobId)); if (job == null) { return(new NotFoundResult()); } JobViewModel jobViewModel = _mapper.Map <JobViewModel>(job); IEnumerable <Job> childJobs = _jobsRepositoryNonAsyncPolicy.Execute(() => _jobRepository.GetChildJobsForParent(jobId)); if (!childJobs.IsNullOrEmpty()) { foreach (Job childJob in childJobs) { jobViewModel.ChildJobs.Add(_mapper.Map <JobViewModel>(childJob)); } } return(new OkObjectResult(jobViewModel)); }
public IActionResult Create() { var vm = new JobViewModel(); SetCategories(vm); return(View(vm)); }
public IActionResult Index(JobViewModel viewmodel) { var jobs = _context.Job.Select(m => m); if (viewmodel.Experience != null) { jobs = jobs.Where(s => s.ExId == Int32.Parse(viewmodel.Experience)); } if (viewmodel.Department != null) { jobs = jobs.Where(s => s.DeId == Int32.Parse(viewmodel.Department)); } if (viewmodel.Location != null) { jobs = jobs.Where(s => s.LId == Int32.Parse(viewmodel.Location)); } jobs = jobs.Where(j => j.Status == true).Where(j => j.ExpireDate >= DateTime.Now); var joblist = jobs.ToList(); foreach (var item in joblist) { item.Location = _context.JobLocation.Where(s => s.Id == item.LId).ToList()[0]; } viewmodel.Jobs = joblist; return(View(viewmodel)); }
public ActionResult CreateJob(JobViewModel job) { if (!ModelState.IsValid) { ViewBag.Error = "Nieprawidłowe dane"; return(View()); } if (db.Jobs.Any(x => x.Title == job.Title)) { ViewBag.Error = "Stanowisko już istnieje"; return(View()); } Jobs newJob = new Jobs() { Title = job.Title, Salary = job.Salary, WorkFromTime = job.FromTime, WorkToTime = job.ToTime }; db.Jobs.Add(newJob); db.SaveChanges(); ViewBag.Success = "Operacja wykonana pomyślnie"; return(View()); }
private JobViewModel GetJobs() { if (cache.TryGetValue(Constant.constantKeyJob, out JobViewModel list)) { return(list); } var model = new JobViewModel(); try { var jobList = context.Job.AsNoTracking().ToList(); model.Jobs = jobList; } catch (Exception ex) { model.isError = true; model.errorDescription = ex.Message; } if (!model.isError) { cache.Set(Constant.constantKeyJob, model, new MemoryCacheEntryOptions { AbsoluteExpiration = DateTime.Now.AddDays(10), Priority = CacheItemPriority.Normal }); } return(model); }
public async Task <JobViewModel> RetrieveJobAndCheckCanBeProcessed(string jobId) { ApiResponse <JobViewModel> response = await _jobsApiClientPolicy.ExecuteAsync(() => _jobsApiClient.GetJobById(jobId)); if (response?.Content == null) { string error = $"Could not find the job with id: '{jobId}'"; _logger.Write(LogEventLevel.Error, error); throw new JobNotFoundException(error, jobId); } JobViewModel job = response.Content; if (job.CompletionStatus.HasValue) { string error = $"Received job with id: '{jobId}' is already in a completed state with status {job.CompletionStatus}"; _logger.Write(LogEventLevel.Information, error); throw new JobAlreadyCompletedException(error, job); } return(job); }
public JobViewModel GetJobView(JobViewModel jobView) { jobView.AgentName = agentRepo.GetOne(jobView.AgentId)?.Name; jobView.ProcessName = processRepo.GetOne(jobView.ProcessId)?.Name; return(jobView); }
// GET: Jobs/Create public ActionResult Create() { var model = new JobViewModel(); jobService.GetJobFrequencies(model); return(View(model)); }
public bool Updating(JobViewModel item) { try { var obj = db.Jobs.Where(a => a.JobID.Equals(item.JobID)).SingleOrDefault(); if (obj != null) { //db.Jobs.Remove(obj); //db.SaveChanges(); obj.Post = item.Post; obj.Bonus = item.Bonus; obj.Experience = item.Experience; obj.Vacancy = item.Vacancy; obj.Description = item.Description; obj.JobID = item.JobID; //db.Jobs.Add(obj); db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public IActionResult PutJob(int id, int jobId, [FromBody] JobViewModel job) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Job _jobDb = _jobRepository.GetSingle(jobId); if (_jobDb == null) { return(NotFound()); } else { //Here _jobDb.JobType = (JobType)Enum.Parse(typeof(JobType), job.JobType); _jobRepository.Commit(); } job = Mapper.Map <Job, JobViewModel>(_jobDb); return(new NoContentResult()); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { if (jobData.Find(id) != null) { Job singleJob = jobData.Find(id); JobViewModel jobViewModel = new JobViewModel() { Name = singleJob.Name, CoreCompetency = singleJob.CoreCompetency, Employer = singleJob.Employer, Location = singleJob.Location, PositionType = singleJob.PositionType }; return(View(jobViewModel)); } ; // TODO #1 - get the Job with the given ID and pass it into the view return(View()); }
private IHttpActionResult InsertJob(JobViewModel JobVM) { try { if (!IsNameJobAvailble(JobVM.Name, JobVM)) { return(Json(new { Result = "ERROR", Message = "Job Name already exists" })); } Job JobADD = new Job { Name = JobVM.Name, IsActive = JobVM.IsActive }; _repository.JobRepository.Add(JobADD); if (_repository.JobRepository.Save((WindowsPrincipal)User) > 0) { var Record = _repository.JobRepository.GetField(JobADD.ID);; return(Json(new { Result = "OK", Record = Record })); } else { return(Json(new { Result = "ERROR", Message = Errors.MessageError })); } } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = Errors.Write(ex) })); } }
private void GivenJobCanBeProcessed() { JobViewModel jobViewModel = NewJobViewModel(_ => _.WithJobId(JobId)); _jobManagement.RetrieveJobAndCheckCanBeProcessed(JobId) .Returns(jobViewModel); }
async private void OnLineTapped(object sender, ItemTappedEventArgs e) { ListView list = sender as ListView; JobViewModel model = list.SelectedItem as JobViewModel; //await Navigation.PushAsync(new TitledNavigationPage(LineViewPages[model.Line], string.Format("{0}: #{1} {2} ft {3}", model.Line, model.Part.PartName,model.Part.CutLength,model.Job.Material))); await Navigation.PushAsync(LineViewPages[model.Line]); }
public async Task <JobViewModel> CreateJobAsync(JobViewModel jobVM) { job = new Job { Industry = jobVM.Industry, InsolvencyID = jobVM.InsolvencyID, EmployerID = jobVM.EmployerID, SalaryFrom = jobVM.SalaryFrom, SalaryTo = jobVM.SalaryTo, IsFullTime = jobVM.IsFullTime, IsPermanent = jobVM.IsPermanent, IsRemote = jobVM.IsRemote, IsLocal = jobVM.IsLocal, IsPartTime = jobVM.IsPartTime, IsTemporary = jobVM.IsRemote, LocationList = jobVM.LocationList, Description = jobVM.Description, Position = jobVM.Position, YearOfExperience = jobVM.YearOfExperience, SkillSet = jobVM.SkillSet, EducationLevel = jobVM.EducationLevel }; await _db.Jobs.InsertOneAsync(job); return(GetJobByID(job._id)); }
public async Task <IActionResult> EditAsync(int id, JobViewModel vm) { if (!ModelState.IsValid) { SetCategories(vm); return(View(vm)); } var job = await _context.Jobs .Include(j => j.Company) .FirstOrDefaultAsync(job => job.Id == id); if (job == null) { return(BadRequest()); } var authResult = await _authorizationService.AuthorizeAsync(User, job, new OwnsJobRequirement(job.Company.Name)); if (authResult.Succeeded) { job = vm.ToModel(job); _context.Entry(job.Category).State = EntityState.Unchanged; await _context.SaveChangesAsync(); return(LocalRedirect("~/").WithSuccess("hurray", "job updated successfully")); } else if (User.Identity.IsAuthenticated) { return(new ForbidResult()); } else { return(new ChallengeResult()); } }
// GET: Jobs/Details/5 public async Task <IActionResult> Details(int?id) { var j = new JobViewModel(); if (id == null) { return(NotFound()); } var job = await _context.Job .Include("JobNotes") .Include("Company") .SingleOrDefaultAsync(m => m.Id == id); j.Id = job.Id; j.Company = job.Company.Name; j.JobTitle = job.JobTitle; j.JobNotes = job.JobNotes; if (job == null) { return(NotFound()); } return(View(j)); }
public ActionResult Create(JobViewModel jobModel) { if (ModelState.IsValid) { List <Skill> skills = new List <Skill>(); if (jobModel.Skills != null && jobModel.Skills.Count() > 0) { foreach (int skillId in jobModel.Skills) { skills.Add(db.Skills.Find(skillId)); } } Job job = new Job() { Title = jobModel.Title, Description = jobModel.Description, Cost = jobModel.Cost, EndDay = jobModel.EndDay, Skills = skills, User = SystemInfo.GetCurrentUser(), Status = JobStatus.Pending }; db.Jobs.Add(job); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.Skills = new MultiSelectList(db.Skills.Select(s => new { Id = s.Id, Name = s.Name }), "Id", "Name"); return(View(jobModel)); }
public ActionResult Edit(string id) { var actor = this.userManager.GetUserAsync(HttpContext.User).Result; var enterprise = this.mongoContext.Enterprises.Find(u => u.Id.Equals(actor.ActorId)).First(); ObjectId objectId = new ObjectId(id); if (!enterprise.Jobs.Contains(objectId)) { TempData["ErrorMessage"] = "You can't do this action."; return(RedirectToAction(nameof(Index))); } var job = this.mongoContext.Jobs.Find(j => j.Id.Equals(objectId)).First(); JobViewModel jobViewModel = new JobViewModel { Title = job.Title, Description = job.Description, Salary = job.Salary, Tags = string.Join(",", job.Tags.ToArray()), Category = job.Category.Id.ToString(), Month = job.Month }; var categories = this.mongoContext.Categories.AsQueryable().ToEnumerable(); TempData["Categories"] = categories; return(View(jobViewModel)); }
public ActionResult Edit(JobViewModel jobVM) { if (ModelState.IsValid) { Job job = db.Jobs.Find(jobVM.Id); if (job == null) { return(HttpNotFound()); } job.Title = jobVM.Title; job.Description = jobVM.Description; job.Cost = jobVM.Cost; job.EndDay = jobVM.EndDay; job.Skills.Clear(); if (jobVM.Skills != null) { List <Skill> skills = new List <Skill>(); foreach (int skillId in jobVM.Skills) { skills.Add(db.Skills.Find(skillId)); } job.Skills = skills; } //db.Entry(job).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobVM)); }
public void Update(JobViewModel jobVM) { var Job = new Job { Id = jobVM.Id, JobType = jobVM.JobType, JobNo = jobVM.JobNo, JobDate = jobVM.JobDate, Value = jobVM.Value, ValueUnit = jobVM.ValueUnit, ImporterId = jobVM.ImporterId, PortId = jobVM.PortId, SupplierId = jobVM.SupplierId, CountryId = jobVM.CountryId, InvoiceNo = jobVM.InvoiceNo, InvoiceDate = jobVM.InvoiceDate, LCNo = jobVM.LCNo, LCDate = jobVM.LCDate, IsActive = jobVM.IsActive, IsDone = jobVM.IsDone }; unitOfWork.JobRepository.Update(Job); unitOfWork.Save(); }
internal static async void AddJob(string fileName, JobViewModel job) { var file = await GetFileFromFileName(fileName); using (var readStream = await file.OpenAsync(FileAccessMode.ReadWrite)) { var xmldoc = XDocument.Load(readStream.AsStreamForRead()); var root = xmldoc.Root; root.Add(new XElement("job", new XElement("jobid", job.JobID), new XElement("jobtitle", job.JobTitle), new XElement("jobdescription", job.JobDescription), new XElement("jobdate", job.JobDate), new XElement("jobcity", job.JobCity), new XElement("company", new XElement("companyid", job.Company.CompanyID), new XElement("companyname", job.Company.CompanyName), new XElement("companylogourl", job.Company.CompanyLogoURL) ))); //await readStream.FlushAsync(); readStream.Size = 0; readStream.Seek(0); root.Document.Save(readStream.AsStreamForWrite()); //root.Document.Save(readStream.AsStreamForWrite()); } }
private static async Task<JobViewModel> CreateJobOfferFromRow(List<HtmlNode> cells) { try { //var tempRest = cells[0].InnerHtml; //var tempRest1 = cells[1].InnerHtml; //var tempRest2 = cells[2].InnerHtml; //var tempRest3 = cells[3].InnerHtml; //var tempRest4 = cells[4].InnerHtml; var date = cells[0].InnerText; if(date == "днес") { date = (DateTime.Today).Date.ToString("dd.MM.yy"); } else if (date == "вчера") { date = (DateTime.Today.AddDays(-1)).Date.ToString("dd.MM.yy"); } var jobTitle = PurifyString(cells[2].Element("a").InnerText); var city = PurifyString(cells[2].LastChild.InnerText); var jobID = cells[2].Element("a").Attributes["href"].Value; string companyLogo; if (cells[3].Element("a") != null) { if (cells[3].Element("a").Element("img") != null) { if (cells[3].Element("a").Element("img").Attributes["src"].Value != null) { companyLogo = cells[3].Element("a").Element("img").Attributes["src"].Value; } else companyLogo = "anonymousLogo"; } else companyLogo = "anonymousLogo"; } else companyLogo = "anonymousLogo"; string companyID; string companyName; if (cells[4].Descendants("a") != null) { var tmpElement = cells[4].Descendants("a").FirstOrDefault(); if (tmpElement != null) { companyID = tmpElement.Attributes["href"].Value; companyName = PurifyString(tmpElement.InnerText); } companyID = "anonymousID"; companyName = PurifyString(cells[4].InnerText); } else { companyID = "anonymousID"; companyName = PurifyString(cells[4].InnerText); } JobViewModel newOffer = new JobViewModel(); newOffer.JobID = jobID; newOffer.JobTitle = jobTitle; newOffer.JobCity = city; newOffer.JobDate = date; newOffer.JobDescription = await GetJobDescription(jobID); newOffer.Company = new CompanyViewModel(); newOffer.Company.CompanyID = companyID; newOffer.Company.CompanyName = companyName; newOffer.Company.CompanyLogoURL = companyLogo; return newOffer; } catch (Exception e) { throw new InvalidOperationException("Error while creating JobModel from Row",e); } }