示例#1
0
        public async Task CreateAsync(FixItTask taskToAdd)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try {
                db.FixItTasks.Add(taskToAdd);
                await db.SaveChangesAsync();

                timespan.Stop();
                log.TraceApi("SQL Database", "FixItTaskRepository.CreateAsync", timespan.Elapsed, "taskToAdd={0}", taskToAdd);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in FixItTaskRepository.CreateAsync(taskToAdd={0})", taskToAdd);
                throw;
            }
        }
        public async Task CreateAsync(FixItTask taskToAdd)
        {
            Stopwatch timespan = Stopwatch.StartNew();
            db = new MyFixItContext();

            try {
                db.FixItTasks.Add(taskToAdd);
                await db.SaveChangesAsync();

                timespan.Stop();
                log.TraceApi("SQL Database", "FixItTaskRepository.CreateAsync", timespan.Elapsed, "taskToAdd={0}", taskToAdd);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in FixItTaskRepository.CreateAsync(taskToAdd={0})", taskToAdd);
                throw;
            }
        }
 public Task CreateAsync(FixItTask taskToAdd)
 {
     context.FixItTasks.Add(taskToAdd);
     return(context.SaveChangesAsync());
 }