Ejemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody] Surveys inputModel)
        {
            try
            {
                var data = await _surveysManager.Find_By_Id(inputModel.Id);

                if (data == null)
                {
                    throw new Exception(MessageConst.DATA_NOT_FOUND);
                }
                inputModel.UpdatedDate = DateTime.Now;
                inputModel.CreatedDate = data.CreatedDate;
                await _surveysManager.Update(inputModel);

                if (inputModel.Questions != null)
                {
                    await _questionsManager.UpdateListQuestion(inputModel.Questions, inputModel.Id);
                }
                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }