Beispiel #1
0
        public HttpResponseMessage LoginByUsername([FromBody] T_UserSingleModel model)
        {
            var result = _userService.LoginByUsername(model);

            var data = new JsonResultBuilder()
                       .SetCode(JsonResultCode.OK)
                       .SetMessage("success")
                       .SetResult(result).Build();

            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent(data.ToString())
            });
        }
        public HttpResponseMessage GetStudentScore([FromBody] StudentSingleModel model)
        {
            var result = _testService.GetStudentScore(model.Id.ToString());

            var data = new JsonResultBuilder()
                       .SetCode(JsonResultCode.OK)
                       .SetMessage("success")
                       .SetResult(result).Build();


            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent(JsonConvert.SerializeObject(data))
            });
        }
        //[Authorize]
        public HttpResponseMessage GetStudentsPagination([FromBody] StudentPagedModel model)
        {
            /* 请求示例:
             * { "PageSize":10, "PageIndex":0, "Name":"赵%"}
             */
            var result = _testService.GetStudentsPagination(model);

            var data = new JsonResultBuilder()
                       .SetCode(JsonResultCode.OK)
                       .SetMessage("success")
                       .SetResult(result.Data, result.Count).Build();

            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent(data.ToString())
            });
        }
        public HttpResponseMessage DeleteStudent([FromBody] StudentSingleModel model)
        {
            throw new ArgumentException("无效的请求参数");
#pragma warning disable IDE0059 // 从不使用分配给符号的值
            var result = _testService.DeleteStudent(model);
#pragma warning restore IDE0059 // 从不使用分配给符号的值
            var data = new JsonResultBuilder()
                       .SetCode(JsonResultCode.OK)
                       .SetMessage("success")
                       .SetEmptyResult().Build();


            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent(JsonConvert.SerializeObject(data))
            });
        }