Пример #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());
        }
Пример #2
0
 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;
     }
 }