Exemple #1
0
 public static void Remove(User entity)
 {
     using (var db = new FHNWPrototypeDB())
     {
         db.Users.Remove(entity);
         db.SaveChanges();
     }
 }
Exemple #2
0
        public static UserViewModel ConvertUserToViewModel(User user)
        {
            UserViewModel itemview = new UserViewModel();

            itemview.Key = user.Key.ToString();
            itemview.FirstName = user.FirstName;
            itemview.LastName = user.LastName;
            itemview.Longitude = user.GeoLocation.Longitude;
            itemview.Latitude = user.GeoLocation.Latitude;
            itemview.ProfilePicture = user.ProfilePicture;
            itemview.UserAccounts = new Dictionary<string, string>();
            itemview.UserAccounts.Clear();
            foreach (UserAccount subitem in user.UserAccounts)
            {
                itemview.UserAccounts.Add(subitem.Key.ToString(), subitem.Email);
            }
            return itemview;
        }
Exemple #3
0
 //private FHNWPrototypeDB db = null;
 //public UserRepository()
 //{
 //    //db = FHNWSimulationDBContext.Current;
 //   // db = new FHNWPrototypeDB();
 //}
 public static void Save(User entity)
 {
     using (var db = new FHNWPrototypeDB())
     {
         User foundUser = null;
         var results = from user in db.Users
                       where user.Key == entity.Key
                       select user;
         foundUser = results.FirstOrDefault();
         foundUser.FirstName = entity.FirstName;
         db.SaveChanges();
     }
 }