Пример #1
0
        public FriendsPage()
        {
            InitializeComponent();
            FriendsRepository repository = new FriendsRepository();

            repository.GetFriends();
        }
Пример #2
0
        public ActionResult Buscar()
        {
            string pesquisar = "";
            var    repo      = new FriendsRepository();

            return(View(repo.GetFriendByString(pesquisar)));
        }
Пример #3
0
        public ActionResult Details(int id)
        {
            var repo = new FriendsRepository();
            var fv   = repo.GetFriendById(id);

            return(View(fv));
        }
Пример #4
0
        public ActionResult Edit(int id)
        {
            var             repository = new FriendsRepository();
            FriendViewModel fv         = repository.GetFriendById(id);

            return(View(fv));
        }
Пример #5
0
 public UnitOfWork(DemoDBContext context)
 {
     _context = context;
     Demos    = new DemoRepository(_context);
     User     = new UserRepository(_context);
     Friends  = new FriendsRepository(_context);
 }
Пример #6
0
        public ActionResult Buscar(string pesquisa)
        {
            try {
                var repo = new FriendsRepository();

                return(View(repo.GetFriendByString(pesquisa)));
            } catch {
                return(View());
            }
        }
Пример #7
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try {
         var repository = new FriendsRepository();
         repository.DeleteFriend(id);
         return(RedirectToAction("Index"));
     } catch {
         return(View());
     }
 }
Пример #8
0
        public virtual void SetUp()
        {
            DataSetRepository    = new DataSetRepository();
            FriendshipRepository = new FriendshipRepository();
            FriendsRepository    = new FriendsRepository();

            RepositoryFactory = new RepositoryFactoryTestUtility()
            {
                DataSets = DataSetRepository, Friendships = FriendshipRepository, Friends = FriendsRepository
            };
        }
Пример #9
0
        public UnitOfWork()
        {
            _context = new TContext();

            Customer = new CustomerRepository(_context);
            Line     = new LineRepository(_context);
            Sms      = new SmsRepository(_context);
            Call     = new CallRepository(_context);
            Payment  = new PaymentRepository(_context);
            Package  = new PackageRepository(_context);
            Friends  = new FriendsRepository(_context);
            Employee = new EmployeeRepository(_context);
        }
Пример #10
0
        // ordenar lista
        public ActionResult Index()
        {
            var repository = new FriendsRepository();
            var friends    = repository.GetAllFriends();

            return(View(
                       friends.Select(a => new FriendViewModel {
                Id = a.Id,
                FristName = a.FristName,
                LastName = a.LastName,
                BirthDate = a.BirthDate
            })));
        }
        public void CreateFriend_Failed_ReturnsNullDoesntThrow()
        {
            var dbMock = new Mock <IDb <Friend> >();

            dbMock.Setup(db => db.Insert(It.IsAny <Friend>()))
            .Throws <Exception>()
            .Verifiable();
            var friendsRepository = new FriendsRepository(dbMock.Object);

            var friend = friendsRepository.CreateFriend(0, 1);

            Assert.IsNull(friend);
            dbMock.Verify();
        }
Пример #12
0
        private async Task <Boolean> GetFriends()
        {
            this.Friends = await FriendsRepository.GetFriends();

            RaiseAll();
            if (this.Friends.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void CreateFriend_Success_ReturnsFriend()
        {
            var dbMock = new Mock <IDb <Friend> >();

            dbMock.Setup(db => db.Insert(It.IsAny <Friend>()))
            .Callback((Friend f) => { f.Id = 0; })
            .Verifiable();
            var friendsRepository = new FriendsRepository(dbMock.Object);

            var friend = friendsRepository.CreateFriend(0, 1);

            Assert.IsNotNull(friend);
            Assert.AreEqual(0, friend.Id);
            dbMock.Verify();
        }
        public void GetFriendsOfUser_SuccessNoFriends_ReturnsEmptyList()
        {
            var dbMock = new Mock <IDb <Friend> >();

            dbMock.Setup(db => db.Select(1, "WHERE userId1 = @userId OR userId2 = @userId", It.IsAny <SqlParameter[]>()))
            .Returns(default(List <Friend>))
            .Verifiable();
            var friendsRepository = new FriendsRepository(dbMock.Object);

            var friends = friendsRepository.GetFriendsOfUserByStatus(0);

            Assert.IsNotNull(friends);
            Assert.AreEqual(0, friends.Count());
            dbMock.Verify();
        }
Пример #15
0
        static void Main(string[] args)
        {
            //DAL.Context.MtContext mt = new DAL.Context.MtContext();
            //var list = from f in mt.Friends
            //           select f;
            //if(list.Count()>0)
            //    System.Console.WriteLine("not null");
            MtContext         mtContext = new MtContext();
            FriendsRepository fr        = new FriendsRepository(mtContext);
            Friends           f         = new Friends();

            f.Name  = "Pearl";
            f.Title = "Sily";
            fr.Add(f);
            System.Console.ReadKey();
        }
Пример #16
0
        public ActionResult Create(FormCollection collection)
        {
            var FristName = collection["FristName"];
            var LastName  = collection["LastName"];
            var BirthDate = collection["BirthDate"];
            var date      = DateTime.Parse(BirthDate);

            try {
                var repository = new FriendsRepository();
                repository.InsertFriend(FristName, LastName, date);
                return(RedirectToAction("Index"));
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                return(View());
            }
        }
Пример #17
0
        public IHttpActionResult UpdateFriendRequest(Guid FriendUserId, bool Accepted)
        {
            FriendRequestRepository friendReqRep = new FriendRequestRepository();
            FriendsRepository       friendRep    = new FriendsRepository();
            UserRepository          userRep      = new UserRepository();
            User user = userRep.GetUserByEmail(User.Identity.Name);

            if (Accepted)
            {
                friendRep.AddUserFriend(user.Id, FriendUserId);
                friendRep.AddUserFriend(FriendUserId, user.Id);
            }

            friendReqRep.RemoveFriendRequest(FriendUserId, user.Id);

            return(Ok());
        }
Пример #18
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            var repository = new FriendsRepository();

            try {
                FriendViewModel fvm = new FriendViewModel();

                fvm.Id        = Int32.Parse(collection["Id"]);
                fvm.FristName = collection["FristName"];
                fvm.LastName  = collection["LastName"];
                fvm.BirthDate = DateTime.Parse(collection["BirthDate"]);
                repository.UpdateFriend(fvm);
                return(RedirectToAction("Index"));
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                return(View());
            }
        }
Пример #19
0
 public UnitOfWork(DataContext context)
 {
     _context      = context;
     Users         = new UsersRepository(_context);
     Photos        = new PhotosRepository(_context);
     Groups        = new GroupsRepository(_context);
     Memberships   = new MembershipsRepository(_context);
     Auths         = new AuthRepository(_context);
     Comments      = new CommentsRepository(_context);
     Achievements  = new AchievementsRepository(_context);
     Cities        = new CitiesRepository(_context);
     Countries     = new CountriesRepository(_context);
     Locations     = new LocationsRepository(_context);
     Matchdays     = new MatchdaysRepository(_context);
     MatchStatuses = new MatchStatusesRepository(_context);
     Friends       = new FriendsRepository(_context);
     Messages      = new MessagesRepository(_context);
     Chats         = new ChatsRepository(_context);
 }
Пример #20
0
        public IHttpActionResult GetProfileInfo(Guid?Id)
        {
            UserRepository     db        = new UserRepository();
            UserInfoRepository db2       = new UserInfoRepository();
            FriendsRepository  FriendRep = new FriendsRepository();
            User        user;
            ProfileInfo profileinfo;

            if (Id.HasValue)
            {
                user        = db.GetUser(Id.Value);
                profileinfo = db2.GetUserProfileInfo(Id.Value);
            }
            else
            {
                user        = db.GetUserByEmail(User.Identity.Name);
                profileinfo = db2.GetUserProfileInfo(user.Id);
            }

            ProfileViewModel viewmodel = new ProfileViewModel()
            {
                Id                = user.Id,
                FirstName         = user.FirstName,
                LastName          = user.LastName,
                Email             = user.Email,
                Gender            = user.Gender,
                BirthDate         = user.BirthDate,
                Work              = profileinfo.Werk,
                School            = profileinfo.School,
                Hometown          = profileinfo.Woonplaats,
                Relation          = profileinfo.RelatieStatus,
                Hobby             = profileinfo.Hobbies,
                MemberSince       = user.CreatedDate,
                ProfilePictureUrl = user.ProfilePictureUrl,
                Motto             = profileinfo.Motto,
                AboutMe           = profileinfo.AboutMe,
                Friends           = FriendRep.GetUserFriends(user.Id)
            };

            return(Ok(viewmodel));
        }
Пример #21
0
        private async void ExecuteNavigatedTo(NavigateTo obj)
        {
            if (obj.Name == "loaded")
            {
                Type view = (Type)obj.View;
                if (view == (typeof(ZoekVrienden)))
                {
                    //loaded
                    Loaded();
                }
            }

            if (obj.Name == "friend_accepted")
            {
                User.All user     = JsonConvert.DeserializeObject <User.All>(obj.Data.ToString());
                bool     accepted = (bool)obj.Result;
                Response response = Task.FromResult <Response>(await FriendsRepository.PostFriend(user.User.ID, MainViewVM.USER.ID, accepted)).Result;

                if (response.Success == true)
                {
                    Messenger.Default.Send <Dialog>(new Dialog()
                    {
                        Message = user.User.ToString() + " is toegevoegd",
                        ViewOk  = typeof(ZoekVrienden)
                    });

                    Libraries.Socket socketSend = new Libraries.Socket()
                    {
                        To = user.User.ID, From = MainViewVM.USER.ID, Status = true
                    };

                    MainViewVM.socket.Emit("friend_ADDED:send", JsonConvert.SerializeObject(socketSend));
                }
                else
                {
                    //iets misgelopen
                }
            }
        }
Пример #22
0
        private async void AddFriend()
        {
            //todo: friends api
            User.All user = this.SelectedUser;

            List <Friend.All> friends = await FriendsRepository.GetFriends();

            if (friends != null)
            {
                var items = friends.Where(r => r.User2.ID == user.User.ID).ToList();
                if (items != null && items.Count > 0)
                {
                    Messenger.Default.Send <Dialog>(new Dialog()
                    {
                        Message = "U hebt al deze vriend.",
                        Ok      = "Ok"
                    });
                }
                else
                {
                    Libraries.Socket socketSend = new Libraries.Socket()
                    {
                        From = MainViewVM.USER.ID, To = user.User.ID, Status = true
                    };

                    MainViewVM.socket.Emit("friend_REQUEST:send", JsonConvert.SerializeObject(socketSend));
                    CloseModal();

                    Messenger.Default.Send <Dialog>(new Dialog()
                    {
                        Message = "Vrienddschapsverzoek is verzonden",
                        Ok      = "Ok"
                    });
                }
            }
        }
Пример #23
0
 public FriendsController(FriendsRepository db)
 {
     _context = db;
 }
Пример #24
0
        public IActionResult DisplayInfoHTML(int id)
        {
            var model = FriendsRepository.GetFriendsInfoById(id);

            return(PartialView("_PersonView", model));
        }
Пример #25
0
        public IActionResult DisplayInfo(int id)
        {
            var model = FriendsRepository.GetFriendsInfoById(id);

            return(Json(model));
        }
Пример #26
0
        private async Task GetFriends()
        {
            this.Loading = true;
            RaisePropertyChanged("Loading");

            friends_all = await FriendsRepository.GetFriends();

            //Try catch errond om te zorgen dat hij niet crasht bij lege bobs.
            if (this.friends_all != null)
            {
                for (int i = 0; i < friends_all.Count(); i++)
                {
                    try
                    {
                        Friend.All item = friends_all[i];
                        if (item.Location == null)
                        {
                            break;
                        }

                        item.VisibleShow      = Visibility.Collapsed;
                        item.ShowCommand      = new RelayCommand <object>(e => ShowFriend(e));
                        item.RouteCommand     = new RelayCommand <object>(e => mapItem_Friend(e));
                        item.RouteCommandText = "Toon route";

                        BasicGeoposition tempbasic = new BasicGeoposition();
                        //Locaties omzetten en in de tijdelijke posities opslaan.
                        tempbasic.Latitude  = ((Location)item.Location).Latitude;
                        tempbasic.Longitude = ((Location)item.Location).Longitude;

                        //Omzetten van tijdelijk punt naar echte locatie (anders krijg je die niet in de mapIconFeestLocation.Location)
                        Geopoint temppoint = new Geopoint(tempbasic);

                        MapIcon mapIconFeestLocation = new MapIcon();
                        mapIconFeestLocation.Location = temppoint; //Opgehaalde locatie
                                                                   //mapIconFeestLocation.Title = feest.Name; //Naam van het feestje;
                        mapIconFeestLocation.Image = MainViewVM.Pins.UserPin;
                        mapIconFeestLocation.Title = item.User1.ToString();
                        this.Map.MapElements.Add(mapIconFeestLocation);//Marker op de map zetten.
                    }
                    catch (Exception ex)
                    {
                    }
                }

                try
                {
                    var          newControl = new MapItemsControl();
                    ZoekVrienden vindrit    = MainViewVM.MainFrame.Content as ZoekVrienden;

                    newControl.ItemsSource  = friends_all;
                    newControl.ItemTemplate = (DataTemplate)vindrit.Resources["FriendsMapTemplate"] as DataTemplate;



                    AddOrUpdateChild(newControl);
                }
                catch (Exception)
                {
                }



                this.Friends = friends_all.Take(10).ToList();
                this.Loading = false;
                RaiseAll();
            }
        }
Пример #27
0
        public ActionResult Delete(int id)
        {
            var repository = new FriendsRepository();

            return(View(repository.GetFriendById(id)));
        }