Exemple #1
0
        public async Task <IActionResult> PutSynchronizationStep([FromRoute] int id, [FromBody] SynchronizationStep synchronizationStep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != synchronizationStep.Id)
            {
                return(BadRequest());
            }

            synchronizationStep.UpdatedAt = DateTimeOffset.Now;

            _context.Entry(synchronizationStep).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SynchronizationStepExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(_context.SynchronizationSteps.Find(id)));
        }
Exemple #2
0
        public async Task <IActionResult> PostSynchronizationStep([FromBody] SynchronizationStep synchronizationStep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var now = DateTimeOffset.Now;

            synchronizationStep.CreatedAt = now;
            synchronizationStep.UpdatedAt = now;

            _context.SynchronizationSteps.Add(synchronizationStep);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSynchronizationStep", new { id = synchronizationStep.Id }, synchronizationStep));
        }