コード例 #1
0
        public ActionResult GetContactEmails(string customerName)
        {
            string errMsg = "";

            try
            {
                var customer = customerRepo.Find(customerName);
                if (customer != null)
                {
                    var contactEmails = customerContactRepo.FindContactEmailsByCustomerId(customer.Id).ToList();
                    if (contactEmails.Count() > 0)
                    {
                        return(Json(
                                   contactEmails, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        errMsg = "No contacts!";
                    }
                }
                else
                {
                    errMsg = "This customer" + customerName + "not exist!";
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            return(Json(new{ err = errMsg }, JsonRequestBehavior.AllowGet));
        }