Example #1
0
 public void InsertOrUpdate(USERSINFORMATION user)
 {
     if (user.UserName == default(string)) // New entity
     {
         _context.Entry(user).State = EntityState.Added;
     }
     else        // Existing entity
     {
         _context.Entry(user).State = EntityState.Modified;
     }
 }
 public void Update(User item)
 {
     try {
         _context.Entry(item).State =
             Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #4
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            using var transaction = _context.Database.BeginTransaction();

            _context.Entry(user).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            var integrationEventData = System.Text.Json.JsonSerializer.Serialize <object>(new { id = user.ID, newname = user.Name, version = user.Version });

            _context.IntregationEventOutBox.Add(new IntregationEvent {
                Event = "user.update", Data = integrationEventData
            });

            _context.SaveChanges();
            transaction.Commit();

            _integrationEventSenderService.StartPublishingOutstandingIntegrationEvents();

            return(NoContent());
        }
Example #5
0
 public void Update(User item)
 {
     _context.Entry(item).State =
         Microsoft.EntityFrameworkCore.EntityState.Modified;
     _context.SaveChanges();
 }