// GET: api/Salesperson
        public IEnumerable <Salesperson> Get()
        {
            var faulted = new List <Salesperson>();

            try
            {
                return(db.GetAll());
            }
            catch (DatabaseLink.DataLayerArgumentException e)
            {
                faulted.Add(new Salesperson()
                {
                    IsFaulted = true,
                    DataLayerArgumentException = e.Message
                });
            }
            catch (DatabaseLink.DataLayerException e)
            {
                if (faulted.Count == 0)
                {
                    faulted.Add(new Salesperson()
                    {
                        IsFaulted = true
                    });
                }
                faulted[0].DataLayerException = e.Message;
            }
            return(faulted.AsEnumerable());
        }
Ejemplo n.º 2
0
        public void DBSalespersonTest_GetAll()
        {
            DBSalesperson dbconn = new DBSalesperson();

            IEnumerable <Salesperson> result = dbconn.GetAll();

            Assert.AreNotEqual(0, result.ToList().Count);
        }
Ejemplo n.º 3
0
        public void DBSalespersonTest_Persist_Delete()
        {
            DBSalesperson dBSalesperson = new DBSalesperson();
            Salesperson   person        = new Salesperson()
            {
                Name = "Test", LastName = "Object"
            };

            dBSalesperson.Persist(person);

            Salesperson salesman = dBSalesperson.GetAll().SingleOrDefault(x =>
            {
                return(x.Name.Equals("Test") && x.LastName.Equals("Object"));
            });

            dBSalesperson.Delete(salesman.Id);
        }