public IHttpActionResult PutRegisterApplicant(int id, RegisterApplicant registerApplicant) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != registerApplicant.RegisterApplicantId) { return(BadRequest()); } db.Entry(registerApplicant).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RegisterApplicantExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Delete(int id) { db.Entry(new OnlineJobSite { OnlineJobSiteId = id }).State = EntityState.Deleted; db.SaveChanges(); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job job = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId }; context.Jobs.Add(job); context.SaveChanges(); foreach (string sk in selectedSkills) { Skill foundSkill = context.Skills.Find(int.Parse(sk)); JobSkill jobSkill = new JobSkill { SkillId = foundSkill.Id, JobId = job.Id }; context.JobSkills.Add(jobSkill); } context.SaveChanges(); return(Redirect("/Home")); } return(View("/Add", addJobViewModel)); }
public void Delete(int id) { db.Entry(new JobApplicant { JobApplicantId = id }).State = EntityState.Deleted; db.SaveChanges(); }
internal static async Task CreateVendorInvoiceRecord(int id, string regNumber, string cHECK, string iNVOICE_NUMBER, DateTime?dATE_PAID, int superServiceOrderId) { Console.WriteLine($"Adding Vendor Invoice Record for {regNumber}"); Trace.WriteLine($"{regNumber}, , Adding Vendor Invoice Record "); using (var context = new JobDbContext(connectionString)) { var vendorInvoice = new VendorInvoice { SuperServiceOrderId = superServiceOrderId, VendorInvoiceNumber = iNVOICE_NUMBER, LastPaidDate = dATE_PAID.GetValueOrDefault(), GPDocNum = "Migration", LastPaidCheckNumber = cHECK, VendorInvoiceDate = dATE_PAID.GetValueOrDefault(DateTime.UtcNow) }; context.VendorInvoice.Add(vendorInvoice); context.SaveChanges(); var piEntity = context.PayableItem.Find(id); piEntity.VendorInvoiceId = vendorInvoice.Id; context.SaveChanges(); } }
internal static async Task CreateInvoiceRecord(int id, string regNumber, string cHECK, string iNVOICE_NUMBER, DateTime?dATE_PAID, DateTime?aCTUAL_POSTED, int superServiceOrderId) { Console.WriteLine($"Adding Invoice Record for {regNumber}"); Trace.WriteLine($"{regNumber}, , Adding Invoice Record "); using (var context = new JobDbContext(connectionString)) { var invoice = new Invoice { SuperServiceOrderId = superServiceOrderId, InvoiceNumber = iNVOICE_NUMBER, LastPaidDate = dATE_PAID.GetValueOrDefault(), LastPaidCheckNumber = cHECK, BillToType = "Account", InvoiceDate = aCTUAL_POSTED.GetValueOrDefault(DateTime.UtcNow) }; context.Invoice.Add(invoice); context.SaveChanges(); var piEntity = context.BillableItem.Find(id); piEntity.InvoiceId = invoice.Id; context.SaveChanges(); } }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId, }; context.Jobs.Add(newJob); context.SaveChanges(); //List<JobSkill> existingItems = context.JobSkills // .Where(js => js.JobId == job); foreach (string skill in selectedSkills) { JobSkill newJobSkill = new JobSkill { JobId = newJob.Id, SkillId = int.Parse(skill) }; context.JobSkills.Add(newJobSkill); } context.SaveChanges(); return(Redirect("/Home")); } return(View("Add")); }
public IActionResult AddJob(AddJobViewModel addJobViewModel, String[] selectedSkills) { if (ModelState.IsValid) { Job job = new Job { Name = addJobViewModel.JobName, EmployerId = addJobViewModel.EmployerId }; context.Jobs.Add(job); context.SaveChanges(); foreach (String selSkill in selectedSkills) { JobSkill jobSkill = new JobSkill(job.Id, int.Parse(selSkill)); context.JobSkills.Add(jobSkill); } context.SaveChanges(); return(Redirect("/Home")); } List <Employer> employers = context.Employers.ToList(); addJobViewModel.Employers = new List <SelectListItem>(); foreach (var employer in employers) { addJobViewModel.Employers.Add(new SelectListItem { Value = employer.Id.ToString(), Text = employer.Name }); } addJobViewModel.Skills = context.Skills.ToList(); return(View(addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId }; context.Jobs.Add(newJob); context.SaveChanges(); foreach (string skill in selectedSkills) { int skillId = int.Parse(skill); JobSkill jobSkill = new JobSkill { JobId = newJob.Id, SkillId = skillId }; context.JobSkills.Add(jobSkill); } context.SaveChanges(); return(Redirect("/Home")); } List <Employer> employers = context.Employers.ToList(); List <Skill> skills = context.Skills.ToList(); AddJobViewModel viewModel = new AddJobViewModel(employers, skills); return(View("AddJob", viewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel viewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = viewModel.Name, Employer = context.Employers.Find(viewModel.Id), }; context.Jobs.Add(newJob); context.SaveChanges(); foreach (string skill in selectedSkills) { JobSkill jobSkill = new JobSkill { JobId = newJob.Id, /* Job = newJob, */ SkillId = int.Parse(skill), Skill = context.Skills.Find(int.Parse(skill)) }; context.JobSkills.Add(jobSkill); } context.SaveChanges(); return(Redirect("/home")); } AddJobViewModel anotherViewModel = new AddJobViewModel(context.Employers.ToList(), context.Skills.ToList()); return(View("AddJob", anotherViewModel)); }
public ActionResult <Job> AltaJob(Job job) { _context.Jobs.Add(job); _context.SaveChanges(); return(CreatedAtAction("ConsultarJob", new Job { Id = job.Id }, job)); }
public IActionResult Add(Employer employer) { if (ModelState.IsValid) { context.Employers.Add(employer); context.SaveChanges(); return(Redirect("/Skill/")); } return(View("Add", employer)); }
public IActionResult Add(Skill skill) { if (ModelState.IsValid) { context.Skills.Add(skill); context.SaveChanges(); return(Redirect("/Skill/")); } return(View("Add", skill)); }
public ActionResult Create([Bind(Include = "Id,Title,Description,ValidDate,Location,Count,Wage,CompanyId")] Job job) { if (ModelState.IsValid) { ctx.Jobs.Add(job); ctx.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CompanyId = new SelectList(ctx.Companies, "Id", "Name", job.CompanyId); return(View(job)); }
public IActionResult Add(AddJobViewModel addJobViewModel, List <string> Requirements, List <string> Benefits, List <string> TagNames) { if (ModelState.IsValid) { var currentUser = HttpContext.User.Identity.Name; Job newJob = new Job() { Name = addJobViewModel.Name, DatePosted = DateTime.Now, Location = addJobViewModel.Location, PositionLevel = addJobViewModel.PositionLevel, PositionType = addJobViewModel.PositionType, Description = addJobViewModel.Description, Employer = currentUser, IsOpened = true }; context.Job.Add(newJob); context.SaveChanges(); foreach (var item in Requirements) { Requirement newRequirement = new Requirement() { RequirementName = item, JobId = newJob.JobId }; context.Requirements.Add(newRequirement); context.SaveChanges(); } ; foreach (var item in Benefits) { Benefit newBenefit = new Benefit() { BenefitName = item, JobId = newJob.JobId }; context.Benefits.Add(newBenefit); context.SaveChanges(); } ; foreach (var item in TagNames) { Tag newTag = new Tag() { TagName = item, JobId = newJob.JobId }; context.Tag.Add(newTag); context.SaveChanges(); } return(RedirectToAction("ViewJob", new { id = newJob.JobId })); } // If we get here, something's wrong and re-render the form return(View()); }
public IActionResult Add(AddSkillViewModel skill) { if (ModelState.IsValid) { context.Skills.Add(new Skill { Name = skill.Name, Description = skill.Description }); context.SaveChanges(); return(Redirect("/Skill/")); } return(View("Add", skill)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) //added instance of AddJobViewModel { if (ModelState.IsValid) { Job job = new Job { Name = addJobViewModel.JobName, EmployerId = addJobViewModel.EmployerId, JobSkills = new List <JobSkill>() }; foreach (string skillId in selectedSkills) { JobSkill jobSkill = new JobSkill() { //JobId = job.Id, Job = job, SkillId = int.Parse(skillId) }; context.JobSkills.Add(jobSkill); } context.Jobs.Add(job); context.SaveChanges(); return(Redirect("/")); } return(View(addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, String[] selectedSkills) { //String[] selectedSkills = new String[]; if (ModelState.IsValid) { Job job = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId, Employer = context.Employers.Find(addJobViewModel.EmployerId) }; for (int i = 0; i < selectedSkills.Length; i++) { JobSkill newjobSkill = new JobSkill { JobId = job.Id, Job = job, SkillId = Int32.Parse(selectedSkills[i]) }; context.JobSkills.Add(newjobSkill); } context.Jobs.Add(job); context.SaveChanges(); return(Redirect("Index")); } return(View("Add", addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId }; foreach (string skill in selectedSkills) { JobSkill newJobSkill = new JobSkill { JobId = newJob.Id, Job = newJob, SkillId = Int32.Parse(skill) }; context.JobSkills.Add(newJobSkill); } context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("Index")); } return(View("Add", addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { int employerId = int.Parse(addJobViewModel.Employers.ElementAt(0).Value); Employer employer = (Employer)context.Employers.Where(e => e.Id == employerId); Job newJob = new Job { Name = addJobViewModel.Name, Employer = employer, EmployerId = employerId }; foreach (string skill in selectedSkills) { JobSkill newJobSkill = new JobSkill(); newJobSkill.JobId = newJob.Id; newJobSkill.Job = newJob; newJobSkill.SkillId = int.Parse(skill); newJobSkill.Skill = (Skill)context.Skills.Where(s => s.Id == int.Parse(skill)); context.JobSkills.Add(newJobSkill); } context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("/Index")); } return(View(addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId }; context.Jobs.Add(newJob); foreach (var skillId in selectedSkills) { JobSkill newJobSkill = new JobSkill { Job = newJob, SkillId = int.Parse(skillId) }; context.JobSkills.Add(newJobSkill); } context.SaveChanges(); return(Redirect("/")); } List <Employer> possibleEmployer = context.Employers.ToList(); List <Skill> possibleSkill = context.Skills.ToList(); addJobViewModel.addEmployerAndSkill(possibleEmployer, possibleSkill); return(View("Add", addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job job = new Job { Name = addJobViewModel.Name, //EmployerId = addJobViewModel.EmployerId, Employer = context.Employers.Find(addJobViewModel.EmployerId) }; foreach (var skill in selectedSkills) { JobSkill jobSkill = new JobSkill { SkillId = int.Parse(skill), Job = job }; context.JobSkills.Add(jobSkill); } context.Jobs.Add(job); context.SaveChanges(); return(Redirect("Index")); } return(View("AddJob", addJobViewModel)); }
public IActionResult AddJob(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid == false) { return(View(addJobViewModel)); } Job job = new Job { Name = addJobViewModel.Name, Employer = _context.Employers.Find(addJobViewModel.EmployerId), EmployerId = addJobViewModel.EmployerId }; for (int i = 0; i < selectedSkills.Length; i++) { JobSkill puppy = new JobSkill { SkillId = int.Parse(selectedSkills[i]), JobId = job.Id, Job = job }; _context.JobSkills.Add(puppy); } _context.Jobs.Add(job); _context.SaveChanges(); return(Redirect("Index")); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId, Employer = context.Employers.Find(addJobViewModel.EmployerId), }; foreach (string item in selectedSkills) { JobSkill newJobSkill = new JobSkill { JobId = newJob.Id, Job = newJob, SkillId = int.Parse(item), Skill = context.Skills.Find(int.Parse(item)) //Do I need this? }; context.JobSkills.Add(newJobSkill); } context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("Index")); } return(View("Add", addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string [] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, Employer = context.Employers.Find(addJobViewModel.EmployerId) }; for (int i = 0; i < selectedSkills.Length; i++) { JobSkill jobSkill = new JobSkill { SkillId = Int32.Parse(selectedSkills[i]), JobId = newJob.Id, Job = newJob, Skill = context.Skills.Find(Int32.Parse(selectedSkills[i])) }; context.JobSkills.Add(jobSkill); } context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("/Add")); } List <Skill> skills = context.Skills.ToList(); List <Employer> employers = context.Employers.ToList(); AddJobViewModel rainbow = new AddJobViewModel(employers, skills); addJobViewModel.Employers = rainbow.Employers; addJobViewModel.Skills = rainbow.Skills; return(View("AddJob", addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string [] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId }; for (int i = 0; i < selectedSkills.Length; i++) { JobSkill jobSkill = new JobSkill { //Skill = selectedSkills.Skill, SkillId = int.Parse(selectedSkills[i]), JobId = newJob.Id, Job = newJob }; context.JobSkills.Add(jobSkill); } context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("/List")); } return(View("AddJob", addJobViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId, Employer = context.Employers.Find(addJobViewModel.EmployerId) }; foreach (string skill in selectedSkills) { JobSkill jobSkill = new JobSkill { Job = newJob, Skill = context.Skills.Find(int.Parse(skill)) }; context.JobSkills.Add(jobSkill); } context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("/Home")); } return(View("/Add, addJobViewModel")); }
public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) { if (ModelState.IsValid) { // Create job object. Job newJob = new Job() { Name = addJobViewModel.Name, EmployerId = addJobViewModel.EmployerId, Employer = context.Employers.Find(addJobViewModel.EmployerId), JobSkills = new List <JobSkill>() }; // Add selected skills. foreach (string skill in selectedSkills) { JobSkill newJobSkill = new JobSkill { Job = newJob, Skill = context.Skills.Find(int.Parse(skill)) }; context.JobSkills.Add(newJobSkill); } // Update info. context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("/Home")); } return(View("Add", addJobViewModel)); }
public IActionResult ProcessAddEmployerForm(AddEmployerViewModel theViewModel) { if (ModelState.IsValid) { List <Employer> existingEmployers = context.Employers .Where(e => e.Name == theViewModel.Name) .Where(e => e.Location == theViewModel.Location) .ToList(); if (existingEmployers.Count == 0) { Employer theEmployer = new Employer { Name = theViewModel.Name, Location = theViewModel.Location }; context.Employers.Add(theEmployer); context.SaveChanges(); return(Redirect("/Employer")); } else { return(Redirect("/Employer")); } } return(View("Add", theViewModel)); }
public IActionResult ProcessAddJobForm(AddJobViewModel model, string[] selectedSkills) { if (ModelState.IsValid) { Job newJob = new Job { Name = model.Name, EmployerId = model.EmployerId, }; foreach (string skills in selectedSkills) { context.JobSkills.Add(new JobSkill { SkillId = Convert.ToInt32(skills), Job = newJob, JobId = newJob.Id }); } context.Jobs.Add(newJob); context.SaveChanges(); return(Redirect("/home")); } return(View("Add", model)); }