示例#1
0
        public ContactsPage()
        {
            InitializeComponent();
            Title = "Contactos";

            _viewmodel     = new ContactListVM(GoToDetails, ContactsService.Instance);
            BindingContext = _viewmodel;
            Appearing     += ContactsPage_Appearing;
        }
示例#2
0
        public void RemoveContactMustCallServiceWithContact()
        {
            var vm = new ContactListVM(null, mock.Object);

            vm.Initialize().Wait();
            vm.Elements.First().RemoveContactCommand.Execute(
                vm.Elements.First()
                );
            mock.Verify(x => x.Remove(contact), Times.Once);
        }
        public async Task AddEnityTest()
        {
            await Task.Run(() =>
            {
                ContactListVM.AddEntity(contact);
                //check verify
                //ContactListVM.Contacts.Equals(contact);
            });

            Assert.AreEqual(contact.Id, CustomerMock.Object.Entity.Id);
        }
        public ActionResult Index([Bind(Include = "Page, Sort")] PageSortCriteria pageSortCriteria, [Bind(Include = "ContactType, ContactData")] ContactSearchCriteria searchCriteria = null)
        {
            ContactListVM vm = new ContactListVM
            {
                Contacts         = UOW.Contacts.GetAllPaged(pageSortCriteria, searchCriteria),
                PageSortCriteria = pageSortCriteria,
                SearchCriteria   = searchCriteria
            };

            return(View(vm));
        }
示例#5
0
        public ActionResult Contacts()
        {
            var model = new ContactListVM();

            model.Contacts = contactService.GetContactsForGrid().Select(y =>
                                                                        new ContactsGridItemVM()
            {
                Id             = y.Id,
                Name           = y.FirstName + " " + y.LastName,
                Organisation   = y.Organisations.Name,
                OrganisationId = y.Organisations.Id,
                JobTitle       = y.JobTitle,
                Email          = y.Email,
                Country        = y.Country
            }).ToList();

            return(View(model));
        }
        // GET: Contacts
        public ActionResult List()
        {
            ContactsService contactService = new ContactsService();
            ContactListVM   model          = new ContactListVM();

            TryUpdateModel(model);

            List <Contact> contacts = contactService.GetAll().Where(c => c.UserID == AuthenticationService.LoggedUser.ID).ToList();

            if (model.Search != null)
            {
                contacts = contacts.Where(c => (c.FirstName.Trim() + c.LastName.Trim()).Trim().ToLower().Contains(model.Search.Replace(" ", string.Empty).ToLower()) || c.Adress.Contains(model.Search)).ToList();
            }

            switch (model.SortOrder)
            {
            case "fname_desc": contacts = contacts.OrderByDescending(c => c.FirstName).ToList(); break;

            case "lname_asc": contacts = contacts.OrderBy(c => c.LastName).ToList(); break;

            case "lname_desc": contacts = contacts.OrderByDescending(c => c.LastName).ToList(); break;

            case "adress_asc": contacts = contacts.OrderBy(c => c.Adress).ToList(); break;

            case "adress_des": contacts = contacts.OrderByDescending(c => c.Adress).ToList(); break;

            case "fname_asc":
            default:
                contacts = contacts.OrderBy(u => u.FirstName).ToList();
                break;
            }
            int pageSize = 3;

            if (model.PageSize != 0)
            {
                pageSize = model.PageSize;
            }

            int pageNumber = model.Page ?? 1;

            model.Contacts = contacts.ToPagedList(pageNumber, pageSize);

            return(View(model));
        }