public User Update(User user, ICollection <string> propertiesToUpdate = null)
        {
            using (var context = new MasterTrainerContext())
            {
                var existing = context.Users.SingleOrDefault(x => x.Id == user.Id);
                if (existing != null)
                {
                    var properties = typeof(User).GetProperties();
                    if (propertiesToUpdate != null)
                    {
                        properties = properties.Where(x => propertiesToUpdate.Contains(x.Name)).ToArray();
                    }
                    foreach (var property in properties)
                    {
                        if (property.Name != "Id")
                        {
                            property.SetValue(existing, property.GetValue(user));
                        }
                    }
                }
                context.SaveChanges();

                return(existing);
            }
        }
 public User Create(User user)
 {
     using (var context = new MasterTrainerContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
         return(user);
     }
 }