Example #1
0
        public async Task <IActionResult> UpdateStatus([FromBody] DtoUpdateStatusTxSINMI value)
        {
            if (value == null)
            {
                return(BadRequest(ModelState));
            }

            var result = await _repository.TxSINMI.UpdateStatus(value.RetornaTxSINMI());

            if (result.ResultadoCodigo == -1)
            {
                return(BadRequest(result));
            }

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> Create([FromBody] DtoInsertTxSINMI value)
        {
            if (value == null)
            {
                return(BadRequest("Master object is null"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid model object"));
            }

            var ObjectNew = await _repository.TxSINMI.Create(value.RetornaTxSINMI());

            if (ObjectNew.ResultadoCodigo == -1)
            {
                return(BadRequest(ObjectNew));
            }
            else
            {
                if (value.FlgCerrado != null)
                {
                    if (bool.Parse(value.FlgCerrado.ToString()))
                    {
                        var updateStatus = new DtoUpdateStatusTxSINMI {
                            IdSINMI = ObjectNew.IdRegistro, IdUsuarioCierre = int.Parse(value.RegUsuario.ToString()), RegUsuario = value.RegUsuario, RegEstacion = value.RegEstacion
                        };
                        var result = await _repository.TxSINMI.UpdateStatus(updateStatus.RetornaTxSINMI());

                        if (result.ResultadoCodigo == -1)
                        {
                            return(BadRequest(result));
                        }
                    }
                }
            }

            return(Ok(ObjectNew));
        }