示例#1
0
        public AdminModel Update(string login, AdminModel user)
        {
            var userFromBd = GetAdmin(login);

            var type = userFromBd.GetType();

            foreach (var propertyInfo in type.GetProperties())
            {
                var newUserProperty = propertyInfo.GetValue(user);
                if (newUserProperty != null)
                {
                    propertyInfo.SetValue(userFromBd, newUserProperty);
                }
            }

            var filter = Builders <AdminModel> .Filter.Eq(u => u.Login, login);

            Admins.ReplaceOne(filter, userFromBd);
            return(userFromBd);
        }
示例#2
0
 public string Save(AdminModel admin)
 {
     Admins.InsertOne(admin);
     return(admin.Id);
 }