public int UpdateJobTypes(IEnumerable <jobType> jobTypes) { using (IOPContext db = new IOPContext()) { JobTypeConverter jtC = new JobTypeConverter(db); foreach (var jt in jobTypes) { var model = jtC.FromDto(jt); db.Entry(model).State = System.Data.Entity.EntityState.Modified; } return(db.SaveChanges()); } }
public int AddJobTypes(IEnumerable <jobType> jobTypes) { using (IOPContext db = new IOPContext()) { List <JobType> jtList = new List <JobType>(); JobTypeConverter jtC = new JobTypeConverter(db); foreach (var jt in jobTypes) { var model = jtC.FromDto(jt); jtList.Add(model); } db.JobTypes.AddRange(jtList); return(db.SaveChanges()); } }