Ejemplo n.º 1
0
        public ViewResult ListContacts(string sortOrder, string SearchString)
        {
            ViewData["NameSortParm"]  = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["CurrentFilter"] = String.IsNullOrEmpty(SearchString) ? "" : SearchString;

            ContactCompanyViewModel model = new ContactCompanyViewModel();

            model.contacts  = this.contactRepository.getAll(sortOrder, SearchString);
            model.companies = this.companyRepository.getAll();

            return(View("../Administration/Contact", model));
        }
Ejemplo n.º 2
0
        public void EditContact(ContactCompanyViewModel model)
        {
            Contact contact = contactRepository.get(model.id);

            if (contact != null)
            {
                contact.name        = model.name;
                contact.phone1      = model.phone1;
                contact.phone2      = model.phone2;
                contact.address     = model.address;
                contact.email       = model.email;
                contact.legalPerson = model.legalPerson;
                contact.job         = model.job;
                contact.company     = companyRepository.get(model.companyId) == null ? null : companyRepository.get(model.companyId);

                this.contactRepository.update(contact);
            }
        }
Ejemplo n.º 3
0
        public ContactCompanyViewModel CreateContact(ContactCompanyViewModel model)
        {
            Contact contact = new Contact
            {
                name        = model.name + " " + model.surname,
                phone1      = model.phone1,
                phone2      = model.phone2,
                address     = model.address,
                email       = model.email,
                legalPerson = model.legalPerson,
                job         = model.job,
                company     = companyRepository.get(model.companyId),
            };

            this.contactRepository.add(contact);

            model.id        = contact.id;
            model.companies = this.companyRepository.getAll();
            model.name      = contact.name;

            return(model);
        }