public ActionResult Put(DbVacancy vacancy) { var result = _service.Update(vacancy); if (result > 0) { return(Ok()); } return(BadRequest()); }
public Vacancy Create(Vacancy vacancy) { DbVacancy dbVacancy = DbVacancy.FromModel(vacancy); dbVacancy = _context.Vacancies .Add(dbVacancy) .Entity; try { _context.SaveChanges(); } catch (DbUpdateException) { throw new ArgumentException("Unable to create Vacancy with such data!"); } return(dbVacancy.ToModel()); }
public Vacancy Delete(Int32 vacancyId) { DbVacancy dbVacancy = _context.Vacancies .SingleOrDefault(v => v.Id == vacancyId) ?? throw new ArgumentException($"No Vacancy with id {vacancyId}!"); dbVacancy = _context.Vacancies .Remove(dbVacancy) .Entity; try { _context.SaveChanges(); } catch (DbUpdateException) { throw new ArgumentException("Unable to delete Vacancy with such data!"); } return(dbVacancy.ToModel()); }
public int Update(DbVacancy vacancy) { var rem = _context.Find <DbVacancy>(vacancy.Id); if (rem == null) { return(0); } if (vacancy.Name != null) { rem.Name = vacancy.Name; } if (vacancy.Salary != null) { rem.Salary = vacancy.Salary; } if (vacancy.Education != null) { rem.Education = vacancy.Education; } if (vacancy.Experience != null) { rem.Experience = vacancy.Experience; } if (vacancy.Know != null) { rem.Know = vacancy.Know; } if (vacancy.Task != null) { rem.Task = vacancy.Task; } var b = _context.Update(rem); return(b); }
public IActionResult test(DbVacancy vacancy) { return(PartialView("test", vacancy)); }
public int Add(DbVacancy vacancy) { var b = _context.Create(vacancy); return(b); }