コード例 #1
0
        public async Task <BCX_CORE.Objects.Tasks.Task> InsertTask(BCX_CORE.Objects.Tasks.Task data, CancellationToken cancellationToken)
        {
            //Update the Created property; Add the new entity and pass the cancellationToken received from the HTTPAPI layer. Save changes
            data.CreatedTS = DateTime.Now;
            var result = await _context.Tasks.AddAsync(data, cancellationToken);

            await _context.SaveChangesAsync();

            return(null);
        }
コード例 #2
0
        public async Task <BCX_CORE.Objects.Tasks.Task> UpdateTask(int Id, BCX_CORE.Objects.Tasks.Task data)
        {
            //Update the Updated property, set the state of the tracked entity to Modified; Update the entity and save those changes
            try
            {
                data.UpdatedTS = DateTime.Now;
                _context.Attach(data).State = EntityState.Modified;
                var result = _context.Tasks.Update(data);
                await _context.SaveChangesAsync();

                return(null);
            }
            catch (Exception Ex)
            {
                throw;
            }
        }