public bool DeleteTripEntity(long id)
        {
            try
            {
                using (LocalTravelAppMSSQLDBContext localTravelAppMSSQLDBContext = new LocalTravelAppMSSQLDBContext())
                {
                    bool removedPerUser = CurrentUserEntity.UserEntity.TripEntities.
                                          Remove(CurrentUserEntity.UserEntity.TripEntities.ToList().Where(t => t.Id == id).FirstOrDefault());

                    TripEntity removedFromTrips = localTravelAppMSSQLDBContext.TripEntities.Remove(localTravelAppMSSQLDBContext.TripEntities.ToList().Where(t => t.Id == id).FirstOrDefault());

                    localTravelAppMSSQLDBContext.SaveChanges();

                    if (removedPerUser && removedFromTrips != null)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }
 public UserEntity RegistrateUser(UserEntity userEntity)
 {
     try
     {
         using (LocalTravelAppMSSQLDBContext localTravelAppMSSQLDBContext = new LocalTravelAppMSSQLDBContext())
         {
             if (localTravelAppMSSQLDBContext.UserEntities.Where(u => u.UserName.Equals(userEntity.UserName)).
                 AsEnumerable().FirstOrDefault(u => u.UserName.Equals(userEntity.UserName)) != null)
             {
                 return(null);
             }
             UserEntity ue = localTravelAppMSSQLDBContext.UserEntities.Add(userEntity);
             ue.TripEntities = new HashSet <TripEntity>();
             localTravelAppMSSQLDBContext.SaveChanges();
             return(ue);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         System.Diagnostics.Debug.WriteLine(e);
         System.Diagnostics.Debug.WriteLine(e);
         return(null);
     }
 }
 public UserEntity UpdateUserData(UserEntity user)
 {
     try
     {
         using (LocalTravelAppMSSQLDBContext localTravelAppMSSQLDBContext = new LocalTravelAppMSSQLDBContext())
         {
             localTravelAppMSSQLDBContext.UserEntities.AddOrUpdate(user);
             localTravelAppMSSQLDBContext.SaveChanges();
             return(user);
         }
     }
     catch (Exception e)
     {
         return(null);
     }
 }
 public bool AddTripEntity(TripEntity tripEntity)
 {
     try
     {
         using (LocalTravelAppMSSQLDBContext localTravelAppMSSQLDBContext = new LocalTravelAppMSSQLDBContext())
         {
             CurrentUserEntity.UserEntity.TripEntities.Add(tripEntity);
             localTravelAppMSSQLDBContext.TripEntities.Add(tripEntity);
             localTravelAppMSSQLDBContext.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }