Example #1
0
        public async Task <IActionResult> PutFactory(int id, Factory factory)
        {
            if (id != factory.ID)
            {
                return(BadRequest());
            }

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

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FactoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            FactoryNodeBuilder fnb = new FactoryNodeBuilder(_context);
            FactoryNode        fn  = fnb.CreateFactoryNode(factory);

            try
            {
                _hubContext.Clients.All.BroadcastMessage("update", fn);
            }
            catch (Exception e)
            {
                //If the hubContext fails to notify others, The caller doesn't care
                //  but we would log the exception
            }

            return(NoContent());
        }
Example #2
0
 public void Update(T obj)
 {
     context.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     context.SaveChanges();
 }