示例#1
0
        public ActionResult UpdatePerson(PersonDto person)
        {
            try
            {
                _personService.Value.UpdatePerson(person);

                return(Json(JsonResponse.CreateSuccess()));
            }
            catch (Exception ex)
            {
                if (ex is ValidationException)
                {
                    return(Json(JsonResponse.CreateError(ex)));
                }

                return(Json(JsonResponse.CreateError(ExceptionDictionary.Instance.GetUserFriendlyMessage(ex))));
            }
        }
        void ProdHandler_onProcessRequest(string Command, EventArgs e)
        {
            ThisContext.Response.ContentType = "text/json";
            switch (Command)
            {
            case "searchfirst":
            {
                string word = Parameters["word"];
                if (!string.IsNullOrWhiteSpace(word))
                {
                    try
                    {
                        NameValueCollection mSection = (NameValueCollection)System.Configuration.ConfigurationManager.GetSection("CollinsDictionary");

                        string baseUrl        = mSection.Get("baseURL") + "/api/v1/";
                        string accessKey      = mSection.Get("accessKey");
                        string dictionaryCode = mSection.Get("dictionaryCode");

                        SkPublishAPI api = new SkPublishAPI(baseUrl, accessKey);

                        IDictionary <string, object> bestMatch = JsonToObject(api.SearchFirst(dictionaryCode, word, "html"));
                        Write(JsonResponse.CreateSuccess(ObjectToJson(bestMatch)));
                    }
                    catch (Exception ex)
                    {
                        Write(JsonResponse.CreateError(ex.Message));
                    }
                }
                else
                {
                    Write(JsonResponse.CreateError("searchtext required"));
                }
                break;
            }

            default:
            {
                Write(JsonResponse.CreateError("Command not implemented"));
                break;
            }
            }
        }
示例#3
0
        public ActionResult SendPerson(Guid personId)
        {
            _personService.Value.SendPerson(personId);

            return(Json(JsonResponse.CreateSuccess()));
        }