コード例 #1
0
        public FamousPersonInfo Get(int id)
        {
            var person = FamousPersonService.FindById(id);

            if (person == null)
            {
                throw new CustomerApiException(HttpStatusCode.NotFound, 1, "该名人不存在");
            }
            return(person);
        }
コード例 #2
0
 public FamousPersonInfo Save([FromBody] FamousPersonInfo value)
 {
     if (value != null && ModelState.IsValid)
     {
         return(FamousPersonService.Save(value));
     }
     else
     {
         throw new CustomerApiException(HttpStatusCode.NotAcceptable, 1, "字段值不合法");
     }
 }
コード例 #3
0
 public void Update(int id, [FromBody] FamousPersonInfo value)
 {
     if (value != null && ModelState.IsValid)
     {
         value.FamousPersonId = id;
         FamousPersonService.Update(value);
         //不处理图片文件了
     }
     else
     {
         throw new CustomerApiException(HttpStatusCode.NotAcceptable, 1, "字段值不合法");
     }
 }
コード例 #4
0
 public FamousPeopleController(FamousPersonService service)
 {
     _service = service;
 }
コード例 #5
0
 public FamousPersonApiController(FamousPersonService famousPersonService,
                                  ILogger <FamousPersonApiController> log)
 {
     _log = log;
     _famousPersonService = famousPersonService;
 }
コード例 #6
0
 public ExceptionHandlerFilter(FamousPersonService famousPersonService,
                               ILogger <ExceptionHandlerAttribute> logger)
 {
     _logger = logger;
     _famousPersonService = famousPersonService;
 }
コード例 #7
0
 public IEnumerable <FamousPersonInfo> Search([FromBody] PersonSearchModel searchModel)
 {
     return(FamousPersonService.Search(searchModel));
 }
コード例 #8
0
 public void Delete(int id)
 {
     FamousPersonService.Delete(id);
 }
コード例 #9
0
 public IEnumerable <FamousPersonInfo> Get()
 {
     return(FamousPersonService.FindAll());
 }
コード例 #10
0
 public EnsurePersonExistsFilter(FamousPersonService famousPersonService,
                                 ILogger <EnsurePersonExistsAttribute> log)
 {
     _log = log;
     _famousPersonService = famousPersonService;
 }