Ejemplo n.º 1
0
        public bool Post(string value)
        {
            if (!value.IsNullOrWhiteSpace())
            {
                Random random       = new Random();
                int    randomNumber = random.Next(0, 10000000);
                var    p            = new Product
                {
                    DateCreated      = DateTime.UtcNow,
                    DateDiscontinued = null,
                    Id           = randomNumber,
                    InternalCode = "CODE_",
                    Name         = value
                };
                _context.Entry(p).State = EntityState.Detached;

                _context.Products.Add(p);
                _context.SaveChanges();
                return(true);
            }

            return(false);
        }