Exemplo n.º 1
0
        public async Task <IHttpActionResult> UpdateExistingMotion(int motionId, AmendmentUpdate model)
        {
            _service.SetUserId(User.Identity.GetUserId());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (model == null)
            {
                return(BadRequest("Request body cannot be empty."));
            }

            if (motionId != model.AmendmentId)
            {
                return(BadRequest($"Body ID ({model.AmendmentId}) and URI ID ({motionId}) mismatch."));
            }

            if (await _service.UpdateExistingAmendmentAsync(model))
            {
                return(Ok("Amendment updated."));
            }

            return(BadRequest("Cannot update amendment."));
        }