public int SaveJob(Job job) { int affectedRows = 0; using (ZavenContext context = new ZavenContext()) { context.Jobs.Add(job); affectedRows = context.SaveChanges(); } return(affectedRows); }
public List <Job> GetAllJobs() { List <Job> sortedJobs = new List <Job>(); using (ZavenContext context = new ZavenContext()) { sortedJobs = context.Jobs.OrderBy(modificationDate => modificationDate.LastUpdatedAt).ToList(); //jobs = sortedJobs.ToList(); } return(sortedJobs); }
public void Update(Job item) { using (ZavenContext context = new ZavenContext()) { var entity = context.Jobs.Find(item.Id); if (entity == null) { return; } context.Entry(entity).CurrentValues.SetValues(item); context.SaveChanges(); } }