public PeopleProfileViewer(PhoneApplicationPage attachedPage)
        {
            this.InitializeComponent();
            this.attachedPage = attachedPage;
            this.peopleProfileViewModel = ViewModelLocator.PeopleViewModel;

            this.Loaded += PeopleProfileViewer_Loaded;

        }
        public ActionResult Edit(int Id)
        {
            PeopleViewModel model = new PeopleViewModel();

            using (CrudMVCRazorFetchEntities1 db = new CrudMVCRazorFetchEntities1())
            {
                var oPeople = db.people.Find(Id);
                model.Name = oPeople.name;
                model.Age  = oPeople.age;
                model.Id   = oPeople.id;
            }

            return(View(model));
        }
        public async Task <PeopleViewModel> Search(SearchModel searchModel)
        {
            var stringPayLoad = JsonConvert.SerializeObject(searchModel);

            var httpContent = new StringContent(stringPayLoad, Encoding.UTF8, "application/json");
            //var obj =await _httpClient.PostJsonAsync("api/People/Search", searchModel);
            var response = await _httpClient.PostAsync("api/people/Search", httpContent);

            string apiResponse = await response.Content.ReadAsStringAsync();

            PeopleViewModel peopleViewModel = JsonConvert.DeserializeObject <PeopleViewModel>(apiResponse);

            return(peopleViewModel);
        }
        public IActionResult EditPeople(int id)
        {
            Person person = new Person();

            //to be replaced by user input
            person.FirstName   = "EditFName";
            person.LastName    = "EditLName";
            person.PhoneNumber = "123456789";
            person.Address     = "EditAddress";

            ps.Edit(id, person);
            peopleViewModel = ps.All();
            return(RedirectToAction(nameof(Add_View_People)));
        }
Beispiel #5
0
        public void People_OnClearData_IsEmpty()
        {
            // Arrange
            var viewModel = new PeopleViewModel();

            viewModel.FetchData();
            Assert.AreEqual(2, viewModel.People.Count(), "Invalid arrangement");

            // Act
            viewModel.ClearData();

            // Assert
            Assert.AreEqual(0, viewModel.People.Count());
        }
Beispiel #6
0
        public async Task <ActionResult> Update(Guid id, PeopleViewModel peopleViewModel)
        {
            if (id != peopleViewModel.Id)
            {
                Notify(DomainError.MessageErrorIdDiferent);
                return(CustomResponse());
            }
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }
            await _peopleService.UpdateAsync(_mapper.Map <People>(peopleViewModel));

            return(CustomResponse(peopleViewModel));
        }
        public MainWindowTestModel()
        {
            Themes.Add(new Theme("Default", "/PresentationFramework.Aero2;component/themes/Aero2.normalcolor.xaml"));
            Themes.Add(new Theme("Aero", "/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"));
            Themes.Add(new Theme("Classic", "/PresentationFramework.Classic;component/themes/Classic.xaml"));
            Themes.Add(new Theme("Luna", "/PresentationFramework.Luna;component/themes/Luna.normalcolor.xaml"));
            _currentTheme = Themes[0];

            BrowseCommand      = new Command(BrowseFile);
            SaveAsCommand      = new Command(SaveFileAs);
            ChangeThemeCommand = new Command(ChangeTheme);
            SaveCommand        = new Command(SaveFile);

            _model = new PeopleViewModel();
        }
Beispiel #8
0
        public void KorangaMoonjiTEst()
        {
            //arrange
            var reader        = new MockReader();
            var mockviewModel = new PeopleViewModel(reader);

            mockviewModel.RefreshPeople();

            //act
            mockviewModel.ClearPeople();


            //assert
            Assert.AreEqual(0, mockviewModel.People.Count());
        }
        public void People_OnClearPeople_IsEmpty()
        {
            // Arrange
            var reader    = new FakeReader();
            var viewModel = new PeopleViewModel(reader);

            viewModel.RefreshPeople();
            Assert.AreNotEqual(0, viewModel.People.Count(), "Invalid Arrange");

            // Act
            viewModel.ClearPeople();

            // Assert
            Assert.AreEqual(0, viewModel.People.Count());
        }
        public BorrowLeanManager()
        {
            this.InitializeComponent();
            this.InitializeApplicationBar();
            base.DataContext = this;
            TiltEffect.SetIsTiltEnabled(this, true);
            this.borrowLeanViewModel = ViewModelLocator.BorrowLeanViewModel;
            this.peopleViewModel = ViewModelLocator.PeopleViewModel;
            this.BorrowOrLeanList.DataContext = this.borrowLeanViewModel;

            loadStatus();

            ToggleCategoryTypeButtonTitle.DataContext = ViewModelLocator.BorrowLeanViewModel;

        }
        // GET: /People/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            People          people          = _service.GetPeopleById(id);
            PeopleViewModel peopleViewModel = Mapper.Map <People, PeopleViewModel>(people);

            if (Request.IsAjaxRequest())
            {
                return(PartialView(peopleViewModel));
            }
            return(View(peopleViewModel));
        }
        public void ClearPeople_OnExecute_PeopleIsEmpty()
        {
            // Arrange
            var repository = GetFakeRepository();
            var vm         = new PeopleViewModel(repository); // Constructor Injection of a Fake Repository

            vm.RefreshPeople();
            Assert.AreEqual(2, vm.People.Count(), "Invalid Arrangement");

            // Act
            vm.ClearPeople();

            // Assert
            Assert.AreEqual(0, vm.People.Count());
        }
Beispiel #13
0
        public void ClearPeople_OnExecute_PeopleIsEmpty()
        {
            // Arrange
            var reader = GetTestReader();
            var vm     = new PeopleViewModel(reader);

            vm.RefreshPeople();
            Assert.AreEqual(2, vm.People.Count(), "Invalid Arrangement");

            // Act
            vm.ClearPeople();

            // Assert
            Assert.AreEqual(0, vm.People.Count());
        }
Beispiel #14
0
        public IActionResult ListPeople()
        {
            var peopleViewModel = new PeopleViewModel()
            {
                People = _context.Person
                         .Include(p => p.Club)
                         .Include(p => p.District)
                         .Include(p => p.PersonRole)
                         .Include(p => p.PersonStatus)
                         .Include(p => p.PersonType)
                         .ToList()
            };

            return(View(peopleViewModel));
        }
Beispiel #15
0
        public void People_OnClearPeople_IsEmpty()
        {
            // Arrange (set up)
            var dataReader      = new FakeReader();
            var peopleViewModel = new PeopleViewModel(dataReader);

            peopleViewModel.RefreshPeople();    // just to be sure that the People property was cleared properly...
            Assert.AreNotEqual(0, peopleViewModel.People.Count(), "Invalid Arrangement");

            // Act
            peopleViewModel.ClearPeople();

            // Assert
            Assert.AreEqual(0, peopleViewModel.People.Count());
        }
Beispiel #16
0
        // это комплексный тест, который Добавляет человека, добавляет ему награду, меняет человеку имя, потом удаляет его из БД
        public void TestComplexByPeople()
        {
            //добавим человека
            PeopleViewModel people = new PeopleViewModel()
            {
                Id            = 0,
                ImageIsEmpty  = true,
                PhotoPeople   = null,
                PhotoMIMEType = "",
                FirstName     = "Test",
                LastName      = "Testov",
                BirthDate     = DateTime.Now.Date.AddYears(-16),
            };
            int saveId = peopleRepo.SavePeople(people);

            Assert.IsTrue(saveId > 0);
            people = peopleRepo.GetPeople(saveId);
            Assert.AreEqual(saveId, people.Id);
            Console.WriteLine("Добавлен человек с Именем = \"{0}\", Фамилией = \"{1}\" и Id = {2}", people.FirstName, people.LastName, saveId);

            // добавим награду Человеку
            int saveAwardId = 0;
            int idAward     = 2;

            saveAwardId = peopleRepo.SavePeopleAward(saveId, idAward);
            //должно вернуть true
            Assert.IsTrue(peopleRepo.CheckPeopleAward(idAward, saveId));
            Console.WriteLine("Добавлена награда c Id = {0} у человека с Id = \"{1}\"", idAward, saveId);

            //удалим награду у человека
            peopleRepo.DeletePeopleAward(saveAwardId);
            //должно вернуть false
            Assert.IsFalse(peopleRepo.CheckPeopleAward(idAward, saveId));
            Console.WriteLine("Награды с Id = \"{0}\" у человека с Id = {1} НЕТ", idAward, saveId);

            // поменяем Имя Человеку
            people.FirstName = "TestName";
            saveId           = peopleRepo.SavePeople(people);
            people           = peopleRepo.GetPeople(saveId);
            Assert.AreEqual(saveId, people.Id);
            Console.WriteLine("Изменено имя у Человека с Id = {0}, Имя = \"{0}\"", people.Id, people.FirstName);

            // удалим Человека
            peopleRepo.DeletePeople(saveId);
            people = peopleRepo.GetPeople(saveId);
            Assert.IsNull(people);
            Console.WriteLine("Человек с Id = \"{0}\" удален", saveId);
        }
Beispiel #17
0
        public PeopleViewModel FindBy(PeopleViewModel search)  //Look efter if is logic
        {
            List <Person> PersonfilterL = new List <Person>(); //tom filterade listan

            foreach (Person item in _personRepo.Read())
            {
                if (item.FirstName.Equals(search.SearchFilter) || // eller tac
                    item.LastName.Equals(search.SearchFilter) ||
                    item.InCity.Equals(search.SearchFilter))
                {
                    PersonfilterL.Add(item); //varje som machar den läggs filtareradelistan
                }
            }
            search.PersonL = PersonfilterL; //Tildelat filtarerade listan
            return(search);
        }
Beispiel #18
0
        public void ClearPeople_OnExecute_PeopleIsEmpty()
        {
            // Arrange
            IPersonReader reader = readerMock.Object;

            var vm = new PeopleViewModel(reader);

            vm.RefreshPeople();
            Assert.AreEqual(2, vm.People.Count());

            // Act
            vm.ClearPeople();

            // Assert
            Assert.AreEqual(0, vm.People.Count());
        }
        public PeopleViewModel FindBy(PeopleViewModel vm)
        {
            if (vm.Search == null)
            {
                return(vm);
            }

            foreach (Person item in _peopleRepo.Read())
            {
                if (item.Name.ToLower().Contains(vm.Search))
                {
                    vm.PeopleList.Add(item);
                }
            }
            return(vm);
        }
        //Constructor when sending a new teacher
        public PeopleViewTeacher(tblTeacher teacher, int newestID) : this()
        {
            //Create a new teacher with the newest teacherID
            teacher = new tblTeacher {
                teacherID = newestID
            };

            //Send it to the view model.
            peopleViewModel  = new PeopleViewModel(teacher);
            this.DataContext = peopleViewModel;

            //Show the teacher controls.
            passwordStack.Visibility = Visibility.Visible;
            this.Title          = "New teacher :";
            labelHeader.Content = "Please enter the following information to create a new teacher.";
        }
        public IActionResult Create(CreatePerson MyCreatePerson)
        {
            if (ModelState.IsValid)
            {
                _peopleService.Add(MyCreatePerson);

                return(RedirectToAction(nameof(Index)));
            }

            PeopleViewModel peopleViewModel = new PeopleViewModel();

            peopleViewModel.MyPersonViewModel = _peopleService.All();
            peopleViewModel.MyCreatePerson    = MyCreatePerson;

            return(View("Index", peopleViewModel));
        }
Beispiel #22
0
        public List <Person> FindByCity(int cityId)
        {
            PeopleViewModel filteredModel = new PeopleViewModel();

            filteredModel = this.All();
            List <Person> filteredList = new List <Person>();

            foreach (Person person in filteredModel.Persons)
            {
                if (person.InCityId == cityId)
                {
                    filteredList.Add(person);
                }
            }
            return(filteredList);
        }
Beispiel #23
0
        //Create people
        public int Create(PeopleViewModel peopleViewModel, byte[] imageBytes)
        {
            try
            {
                //People people = FindPeople(peopleViewModel, imageBytes);
                peopleObj = Bootstrapper.Container.Resolve <IPeopleManager>();
                People people = peopleObj.FindPeople(peopleViewModel, imageBytes);

                return(_peopleService.Create(people));
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLogging(ex);
                throw ex;
            }
        }
Beispiel #24
0
        // сохраняет человека
        public void SavePeople(PeopleViewModel peopleModel)
        {
            try
            {
                People savePeople = new People();

                PeopleModelMapToPeoples(peopleModel, ref savePeople, true);
                dbContext.Set <People>().AddOrUpdate(savePeople);
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.LogException(new Exception(String.Format("Ошибка:\n{0}\n{1}\n{2}", ex.Message, ex.StackTrace, ex.InnerException.StackTrace)));
                throw ex;
            }
        }
        public ActionResult AddPeople(int?id = null)
        {
            PeopleViewModel people = null;

            if (id.HasValue)
            {
                var peopleDTO = peopleService.GetPeople(id.Value);
                people = MapperUtils.mapper.Map <PeopleDTO, PeopleViewModel>(peopleDTO);
            }
            else
            {
                people = new PeopleViewModel();
            }

            return(View(people));
        }
Beispiel #26
0
        // GET: People
        public async Task <IActionResult> Index(int?id, int take = 6, int skip = 0)
        {
            PaginationViewModel <PeopleViewModel> result = new PaginationViewModel <PeopleViewModel>();
            int quantita = await _context.People.CountAsync();

            List <Person> person = new List <Person>();

            person = await _context.People.Skip(skip).Take(take).ToListAsync();

            result.Skip  = skip;
            result.Count = quantita;
            int Count1 = 0;

            if (result.Count % 6 == 0)
            {
                Count1 = (result.Count / 6) - 1;
            }
            else
            {
                Count1 = (result.Count / 6);
            }

            result.Count = Count1;
            var personBadge = await _context.People
                              .Skip(skip)
                              .Take(take)
                              .Select(x => new { IdPerson = x.IdPerson, CountBadge = x.Badge.Count() })
                              .ToListAsync();

            foreach (var p in person)
            {
                PeopleViewModel pv = new PeopleViewModel()
                {
                    Cognome     = p.Cognome,
                    Nome        = p.Nome,
                    Professione = p.Professione,
                    Uri         = p.Uri,
                    IdPerson    = p.IdPerson
                };

                pv.CountBadge = personBadge.
                                FirstOrDefault(x => x.IdPerson == pv.IdPerson).
                                CountBadge;
                result.Data.Add(pv);
            }
            return(View(result));
        }
Beispiel #27
0
 public FilmPage(String url, List <String> backUrl)
 {
     InitializeComponent();
     filmUrl           = url;
     this.backUrl      = backUrl;
     backButton.Click += GoBack;
     if (this.backUrl.Last() == "")
     {
         backButton.Visibility = Visibility.Hidden;
     }
     else
     {
         backButton.Visibility = Visibility.Visible;
     }
     film              = FilmViewModel.GetFilm(url);
     title.Content    += film.title;
     open.Content     += film.opening_crawl + V;
     director.Content += ' ' + film.director;
     producer.Content += ' ' + film.producer;
     release.Content  += ' ' + ConvertToDateTime(film.release_date);
     created.Content  += ' ' + ConvertToDateTime(film.created);
     edited.Content   += ' ' + ConvertToDateTime(film.edited);
     ListCharacters.MouseDoubleClick += CallPeople;
     ListSpaceShip.MouseDoubleClick  += callStarship;
     ListVehicles.MouseDoubleClick   += CallVehicule;
     ListSpecies.MouseDoubleClick    += CallSpecies;
     ListCharacters.Items.Clear();
     ListSpaceShip.Items.Clear();
     ListSpecies.Items.Clear();
     ListVehicles.Items.Clear();
     foreach (String charac in film.characters)
     {
         ListCharacters.Items.Add(PeopleViewModel.GetPeople(charac));
     }
     foreach (String v in film.vehicles)
     {
         ListVehicles.Items.Add(VehicleViewModel.GetVehicle(v));
     }
     foreach (String s in film.starships)
     {
         ListSpaceShip.Items.Add(StarshipViewModel.GetStarship(s));
     }
     foreach (String spe in film.species)
     {
         ListSpecies.Items.Add(SpeciesViewModel.GetSpecies(spe));
     }
 }
        public async Task <IActionResult> Search(PeopleViewModel peopleViewModel)
        {
            SearchModel     searchModel = peopleViewModel.Search;
            PeopleViewModel people;

            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.PostAsJsonAsync("https://localhost:44333/api/people/Search", searchModel))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    people = JsonConvert.DeserializeObject <PeopleViewModel>(apiResponse);
                }
            }

            return(View("Index", people));
        }
Beispiel #29
0
        // GET: PeopleView/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PeopleViewModel model = new PeopleViewModel();

            model.PeopleAgeGroup = getPeopleAgeGroup(null, null);
            model.SelectedPerson = db.People.Find(id);
            if (model.SelectedPerson == null)
            {
                return(HttpNotFound());
            }
            model.DisplayMode = "ReadWrite";
            return(View("Index", model));
        }
Beispiel #30
0
        //Constructor when new student.
        public PeopleView(tblStudent student, int newestID) : this()
        {
            //Create a new student with the newest studentID
            student = new tblStudent {
                studentID = newestID
            };

            //Send it to the view model.
            peopleViewModel  = new PeopleViewModel(student);
            this.DataContext = peopleViewModel;

            //Show the student controls.

            passwordStack.Visibility = Visibility.Visible;
            this.Title          = "New student :";
            labelHeader.Content = "Please enter the following information to create a new student.";
        }
Beispiel #31
0
        public ActionResult Delete(Person p)
        {
            PeopleViewModel m = new PeopleViewModel();

            try
            {
                var personToRemove = PeopleViewModel.people.Find(x => x.Name == p.Name);
                // TODO: Add delete logic here
                m.DeletePerson(personToRemove);
                //PeopleViewModel.people.Remove(personToRemove);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Index", m.GetAllPeople().ToList()));
            }
        }
        public ActionResult CreatePeopleAward(int peopleId, int SelectedAwardID)
        {
            if (peopleId <= 0 || SelectedAwardID <= 0)
            {
                return(View("Error", ErrorHelper.GetErrorModel("Переданы некорректные параметры", "", DEFAULT_BACK_ERROR_URL)));
            }

            if (ModelState.IsValid)
            {
                PeopleViewModel peopleModel;
                peopleModel = GetPeopleModelForEdit(peopleId);
                if (peopleModel == null)
                {
                    return(View("Error", ErrorHelper.GetErrorModel("Не найден человек с таким идентификатором", "", DEFAULT_BACK_ERROR_URL)));
                }

                try
                {
                    repository.SavePeopleAward(peopleId, SelectedAwardID);
                    Logger.logger.Trace(String.Format("Добавлена награда человека:\n PeopleID={0}, AwardID={1}", peopleId, SelectedAwardID));

                    peopleModel = GetPeopleModelForEdit(peopleId);
                    if (peopleModel == null)
                    {
                        return(View("Error", ErrorHelper.GetErrorModel("Не найден человек с таким идентификатором", "", DEFAULT_BACK_ERROR_URL)));
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                    peopleModel.Error = "Запись не добавлена! Ошибка на сервере";
                }

                return(RedirectToAction("EditPeopleAwards", new { id = peopleId }));
            }
            else
            {
                PeopleViewModel peopleModel = GetPeopleModelForEdit(peopleId);
                if (peopleModel == null)
                {
                    return(View("Error", ErrorHelper.GetErrorModel("Не найден человек с таким идентификатором", "", DEFAULT_BACK_ERROR_URL)));
                }

                return(View("EditPeopleAwards", peopleModel));
            }
        }
Beispiel #33
0
        private void openView(object obj)
        {
            switch((string)obj)
            {
                case "People":
                    ViewModel = new PeopleViewModel(dialogService,this);
                    break;

                case "Jobs":
                    ViewModel = new JobsViewModel(dialogService,this);
                    break;

                case "ToDoes":
                    ViewModel = new ToDoesViewModel(dialogService,this);
                    break;
            }
        }
 public MainViewModel()
 {
     CodeBehind = new PeopleViewModel();
     AttachedProperty = new PeopleViewModel();
 }