public IHttpActionResult Insert(AGENTS agent)
        {
            var JsonData = string.Empty;

            try
            {
                var data = dbo.AGENTS.Where(x => x.AGENT_NAME.ToUpper() == agent.AGENT_NAME.ToUpper()).FirstOrDefault();
                if (data != null)
                {
                    JsonData = "agent already exist";
                }
                else
                {
                    dbo.AGENTS.Add(agent);
                    dbo.SaveChanges();
                    JsonData = "record saved successfully";
                }
            }
            catch (Exception ex) {
                JsonData = ex.Message;
            }
            return(Ok(JsonData));
        }
Exemplo n.º 2
0
        //public ProductRepository()
        //{
        //    this.db = new SampleDBEntities();
        //}

        public void AddProduct(Product product)
        {
            db.Products.Add(product);
            db.SaveChanges();
        }