Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Put(int id, Echo data)
        {
            data.Id = id;
            var result = await _echoService.UpdateAsync(data);

            switch (result.ActionStatus.Status)
            {
            case ActionStatusEnum.Success:
                return(result.ActionStatus.SubStatus == ActionSubStatusEnum.Created
                               ? CreateHttpActionResult("EchoAsync", result.ActionStatus.Id)
                               : StatusCode(HttpStatusCode.NoContent));

            case ActionStatusEnum.ValidationError:
                return(ApiControllerExtension.BadRequest(this, result.BrokenValidationRules, data.GetType().Name));
            }

            return(HandleErrorActionResult(result));
        }