// PUT: api/Salesperson/5
 public Salesperson Put(int id, [FromBody] Salesperson value)
 {
     if (value != null)
     {
         var faulted = new Salesperson();
         faulted.IsFaulted = false;
         try
         {
             value.Id = id;
             db.Update(value);
             return(faulted);
         }
         catch (DatabaseLink.DataLayerArgumentException e)
         {
             faulted.IsFaulted = true;
             faulted.DataLayerArgumentException = e.Message;
         }
         catch (DatabaseLink.DataLayerException e)
         {
             faulted.IsFaulted          = true;
             faulted.DataLayerException = e.Message;
         }
         return(faulted);
     }
     return(null);
 }
Exemplo n.º 2
0
        public void DBSalespersonTest_Update_Fail_Name()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(4);

            person.Name = String.Empty;

            db.Update(person);
        }
Exemplo n.º 3
0
        public void DBSalespersonTest_Update_Fail_ID()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(3);

            person.Id = -2;

            db.Update(person);
        }
Exemplo n.º 4
0
        public void DBSalespersonTest_Update_Fail_LastName()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(3);

            person.LastName = null;

            db.Update(person);
        }
Exemplo n.º 5
0
        public void DBSalespersonTest_Update()
        {
            DBSalesperson db      = new DBSalesperson();
            var           person  = db.Get(3);
            string        nameOld = person.Name;
            string        nameNew = "Jason";

            person.Name = nameNew;

            db.Update(person);
            person = null;

            person = db.Get(3);

            Assert.AreEqual(nameNew, person.Name);

            //cleanup
            person.Name = nameOld;
            db.Update(person);
        }