public ViewResult Persons()
        {
            var companyList = new CompanyServices().GetAllOrderedCompanies() ?? new List <Company>();

            if (!companyList.Any())
            {
                ViewBag.Title = "Persons' Information Set Up";
                return(View(Tuple.Create(new List <Company>(), new List <Person>())));
            }

            var personList = new PersonServices().GetAllOrderedPersons() ?? new List <Person>();

            if (!personList.Any())
            {
                ViewBag.Title = "Persons' Information Set Up";
                return(View(Tuple.Create(companyList, new List <Person>())));
            }

            personList.ForEach(m =>
            {
                m.CompanyName = m.Company.Name;
            });

            ViewBag.Title = "Manage Persons' Information";
            return(View(Tuple.Create(companyList, personList)));
        }
Esempio n. 2
0
        public ActionResult GetContactListByCompany(int id)
        {
            var company = new Company();

            try
            {
                if (id < 1)
                {
                    company.Error     = "Invalid Selection!";
                    company.ErrorCode = -1;
                    return(Json(company, JsonRequestBehavior.AllowGet));
                }

                var contactList = new PersonServices().GetAllOrderedPersonsByCompanyId(id);

                if (contactList == null || !contactList.Any())
                {
                    company.Error     = "Company Contact List is empty.";
                    company.ErrorCode = -1;
                    return(Json(company, JsonRequestBehavior.AllowGet));
                }
                return(Json(contactList, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                company.Error     = "An unknown error was Company Information could not be retrieved.";
                company.ErrorCode = -1;
                return(Json(company, JsonRequestBehavior.AllowGet));
            }
        }