Ejemplo n.º 1
0
        public async Task <Associate> Put(int id, [FromBody] Associate associate)
        {
            var entry = _context.Associates.Update(associate);

            await _context.SaveChangesAsync();

            return(entry.Entity);
        }
Ejemplo n.º 2
0
        private static async Task LoadData()
        {
            using (var context = new AssociateContext())
            {
                // add new test data
                Console.WriteLine("Adding Test Data");
                Console.WriteLine("=========\n");

                var assoc1 = new Associate {
                    Name = "Janis Roberts"
                };
                var assoc2 = new Associate {
                    Name = "Kevin Hodges"
                };
                var assoc3 = new Associate {
                    Name = "Bill Jordan"
                };
                var salary1 = new AssociateSalary {
                    Salary = 39500M, SalaryDate = DateTime.Parse("8/4/09")
                };
                var salary2 = new AssociateSalary
                {
                    Salary     = 41900M,
                    SalaryDate = DateTime.Parse("2/5/10")
                };
                var salary3 = new AssociateSalary
                {
                    Salary     = 33500M,
                    SalaryDate = DateTime.Parse("10/08/09")
                };
                assoc1.AssociateSalaries.Add(salary1);
                assoc2.AssociateSalaries.Add(salary2);
                assoc3.AssociateSalaries.Add(salary3);
                context.Associates.Add(assoc1);
                context.Associates.Add(assoc2);
                context.Associates.Add(assoc3);

                // update datastore asynchronoulsy
                await context.SaveChangesAsync();

                await Task.Delay(5000);
            }
        }