示例#1
0
        public async Task <IActionResult> PutChannel(int id, Channel channel)
        {
            if (id != channel.ChannelId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public static void AddGroup(Group group)
 {
     using (var context = new TimerContext())
     {
         context.Users.Attach(group.User);
         context.Groups.Add(group);
         context.SaveChanges();
         context.Entry(group).State = System.Data.Entity.EntityState.Unchanged;
     }
 }