Tests.EmployeeRepositoryEF_Intermediate.Upsert C# (CSharp) Method

Upsert() public method

public Upsert ( Employee employee ) : int
employee Employee
return int
        public int Upsert(Employee employee)
        {
            using (var context = new CodeFirstModels())
            {
                if (employee.EmployeeKey == 0)
                    context.Entry(employee).State = EntityState.Added;
                else
                    context.Entry(employee).State = EntityState.Modified;
                context.SaveChanges();
                return employee.EmployeeKey;
            }
        }
    }