public void Location_Update(Location item) { using (WorkScheduleContext context = new WorkScheduleContext()) { context.Entry <Location>(context.Locations.Attach(item)).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void AddNewLocation(Location item) { using (var context = new WorkScheduleContext()) { // Get the new stuff var added = context.Locations.Add(item); context.SaveChanges(); } }
public void Location_Add(Location item) { using (WorkScheduleContext context = new WorkScheduleContext()) { Location added = null; added = context.Locations.Add(item); context.SaveChanges(); } }
public bool InsertJobSchedule(JobSchedule schedule) { try { _workScheduleContext.JobSchedule.Add(schedule); _workScheduleContext.SaveChanges(); return(true); } catch (System.Exception ex) { Debug.WriteLine(ex.StackTrace); return(false); } }
public bool InsertWorkScheduleItem(WorkScheduleItem item) { try { _workScheduleContext.WorkScheduleItem.Add(item); _workScheduleContext.SaveChanges(); return(true); } catch (System.Exception ex) { Debug.WriteLine(ex.StackTrace); return(false); } }
public bool AddJobItemAsync(JobItem jobItem) { try { _workContext.JobItem.Add(jobItem); _workContext.SaveChanges(); return(true); } catch (SqlException ex) { Debug.WriteLine(ex.StackTrace); return(false); } }
public void UpdateLocation(Location item) { using (var context = new WorkScheduleContext()) { // Edit current location var attached = context.Locations.Attach(item); var existing = context.Entry <Location>(attached); existing.State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void EmployeeSkill_Delete(int employeeskillid) { using (var context = new WorkScheduleContext()) { //example of a physical delete //retrieve the current entity instance based on the incoming parameter var exists = context.EmployeeSkills.Find(employeeskillid); //staged the remove context.EmployeeSkills.Remove(exists); //commit the remove context.SaveChanges(); //a logical delete is actually an update of the instance } }
public void EmployeeSkill_Update(EmployeeSkillItem item) { using (var context = new WorkScheduleContext()) { EmployeeSkill updateItem = new EmployeeSkill { //for an update, you need to supply your PK value EmployeeSkillID = item.EmployeeSkillID, EmployeeID = item.EmployeeID, SkillID = item.SkillID, Level = item.Level, YearsOfExperience = item.YearsOfService, HourlyWage = item.HourlyWage }; context.Entry(updateItem).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public int EmployeeSkill_Add(EmployeeSkillItem item) // this will return PK { using (var context = new WorkScheduleContext()) { EmployeeSkill addItem = new EmployeeSkill { //why no PK set? //PK is an identity PK, no value is needed //However, if PK is NOT an identity spec(Identity Specification = No in the DB), ADD PK here!!! EmployeeID = item.EmployeeID, SkillID = item.SkillID, Level = item.Level, YearsOfExperience = item.YearsOfService, HourlyWage = item.HourlyWage }; context.EmployeeSkills.Add(addItem); context.SaveChanges(); return(addItem.EmployeeSkillID); } }