public void Insert(DataDiscountsJson discounts)
        {
            Discounts ldiscount = new Discounts();

            ldiscount.id_discount    = Convert.ToInt64(discounts.id_discount);
            ldiscount.type_discount  = discounts.type_discount;
            ldiscount.value_discount = Convert.ToDecimal(discounts.value_discount);

            _context.Discounts.Add(ldiscount);
            _context.SaveChanges();
        }
        public void Update(DataDiscountsJson discounts)
        {
            //DataDiscountsJson lDiscount = Find(Convert.ToInt64(discounts.id_discount));
            Discounts lDiscount = new Discounts();

            lDiscount.id_discount    = Convert.ToInt64(discounts.id_discount);
            lDiscount.type_discount  = discounts.type_discount;
            lDiscount.value_discount = Convert.ToDecimal(discounts.value_discount);

            _context.Discounts.Update(lDiscount);
            _context.SaveChanges();
        }
 public void Post([FromBody] DataDiscountsJson value)
 {
     if (value != null)
     {
         if (_discountRepositorio.Find(Convert.ToInt64(value.id_discount)) != null)
         {
             _discountRepositorio.Update(value);
         }
         else
         {
             _discountRepositorio.Insert(value);
         }
     }
 }
        public DataDiscountsJson Find(long id)
        {
            Discounts         ldiscount     = _context.Discounts.FirstOrDefault(t => t.id_discount == id);
            DataDiscountsJson discountsJson = new DataDiscountsJson();

            if (ldiscount == null)
            {
                discountsJson = null;
                return(discountsJson);
            }
            else
            {
                discountsJson.type_discount  = ldiscount.type_discount;
                discountsJson.value_discount = ldiscount.value_discount.ToString();
                return(discountsJson);
            }
        }