コード例 #1
0
        public ActionResult GetStaffProfile(String StaffNumber)
        {
            string errorResult = "{{\"employee_number\":\"{0}\",\"name\":\"{1}\"}}";

            if (string.IsNullOrEmpty(StaffNumber))
            {
                errorResult = string.Format(errorResult, "Error", "Invalid staff number");
                return(Content(errorResult, "application/json"));
            }

            var profile = LINQCalls.getBranchStaffProfile(StaffNumber, 1);

            if (profile == null)
            {
                errorResult = string.Format(errorResult, "Error", "No records found for the staff number");
                return(Content(errorResult, "application/json"));
            }
            else
            {
                return(Json(profile, JsonRequestBehavior.AllowGet));
            }
        }