Example #1
0
        public async Task <IActionResult> GetCustomerConditionsById(Int64 CustomerConditionsId)
        {
            CustomerConditions Items = new CustomerConditions();

            try
            {
                Items = await _context.CustomerConditions.Where(q => q.CustomerConditionId == CustomerConditionsId).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }
Example #2
0
        public async Task <IActionResult> GetCustomerConditionsByClass([FromBody] CustomerConditions _Ccq)
        {
            List <CustomerConditions> Items = new List <CustomerConditions>();

            try
            {
                Items = await _context.CustomerConditions
                        .Where(q => q.IdTipoDocumento == _Ccq.IdTipoDocumento)
                        .Where(q => q.SubProductId == _Ccq.SubProductId)
                        .Where(q => q.DocumentId == _Ccq.DocumentId).ToListAsync();

                Items = (from c in Items
                         select new CustomerConditions
                {
                    LogicalConditionId = c.LogicalConditionId,
                    ConditionId = c.ConditionId,
                    CustomerConditionName = c.CustomerConditionName,
                    CustomerConditionId = c.CustomerConditionId,
                    Description = c.Description,
                    CustomerId = c.CustomerId,
                    SubProductId = c.SubProductId,
                    DocumentId = c.DocumentId,
                    Estado = c.Estado,
                    IdEstado = c.IdEstado,
                    IdTipoDocumento = c.IdTipoDocumento,
                    LogicalCondition = c.LogicalCondition,
                    ValueDecimal = c.ValueDecimal,
                    ValueToEvaluate = c.ValueToEvaluate != null && c.ValueToEvaluate != "" ? Convert.ToDouble(c.ValueToEvaluate).ToString("n2") : "0",
                    ProductId = c.ProductId,
                    ValueString = c.ValueString,
                    FechaCreacion = c.FechaCreacion,
                    FechaModificacion = c.FechaModificacion,
                    UsuarioCreacion = c.UsuarioCreacion,
                    UsuarioModificacion = c.UsuarioModificacion,
                }
                         ).ToList();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }
Example #3
0
        public async Task <ActionResult <CustomerConditions> > Insert([FromBody] CustomerConditions _CustomerConditions)
        {
            CustomerConditions _CustomerConditionsq = new CustomerConditions();

            try
            {
                _CustomerConditionsq = _CustomerConditions;
                _context.CustomerConditions.Add(_CustomerConditionsq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_CustomerConditionsq)));
        }
Example #4
0
        public async Task <IActionResult> Delete([FromBody] CustomerConditions _CustomerConditions)
        {
            CustomerConditions _CustomerConditionsq = new CustomerConditions();

            try
            {
                _CustomerConditionsq = _context.CustomerConditions
                                       .Where(x => x.CustomerConditionId == (Int64)_CustomerConditions.CustomerConditionId)
                                       .FirstOrDefault();

                _context.CustomerConditions.Remove(_CustomerConditionsq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_CustomerConditionsq)));
        }
Example #5
0
        public async Task <ActionResult <CustomerConditions> > Update([FromBody] CustomerConditions _CustomerConditions)
        {
            CustomerConditions _CustomerConditionsq = _CustomerConditions;

            try
            {
                _CustomerConditionsq = (from c in _context.CustomerConditions
                                        .Where(q => q.CustomerConditionId == _CustomerConditions.CustomerConditionId)
                                        select c
                                        ).FirstOrDefault();

                _context.Entry(_CustomerConditionsq).CurrentValues.SetValues((_CustomerConditions));

                //_context.CustomerConditions.Update(_CustomerConditionsq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_CustomerConditionsq)));
        }