public ActionResult Contacts(int Projects, ContactsSearchViewModel search) { ViewBag.ProjectsName = Projectservice.GetnameProjects(Projects); var items = ContactsService.GetAll(Projects, search); ViewBag.Search = search; ViewBag.ProjectId = Projects; return(View("~/Views/Project/Contacts.cshtml", items)); }
// GET api/values public List <Contact> GetContacts() { List <Contact> contacts = new List <Contact>(); logger.Info("Fetching list of contacts"); try { contacts = service.GetAll(); logger.Info("Fetched list of contacts"); } catch (Exception ex) { logger.Error(ex.ToString()); } return(contacts); }
// 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)); }
public ActionResult List() { ContactsService contactsService = new ContactsService(); ContactsListVM model = new ContactsListVM(); TryUpdateModel(model); List <Contact> contacts = contactsService.GetAll().Where(c => c.UserID == AuthenticationManager.LoggedUser.ID).ToList(); if (!String.IsNullOrEmpty(model.Search)) { model.Search = model.Search.Replace(" ", String.Empty); contacts = contacts.Where(c => (c.FirstName + c.LastName).ToLower().Contains(model.Search.ToLower())).ToList(); } switch (model.SortOrder) { case "lname_asc": contacts = contacts.OrderBy(c => c.LastName).ToList(); break; case "lname_desc": contacts = contacts.OrderByDescending(c => c.LastName).ToList(); break; case "fname_desc": contacts = contacts.OrderByDescending(c => c.FirstName).ToList(); break; case "fname_asc": default: contacts = contacts.OrderBy(c => c.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)); }
public IHttpActionResult Get() { return(Ok(Aggregates.Contact.ToClient(_contactService.GetAll()))); }