// 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);
 }
예제 #2
0
        public void DBSalespersonTest_Update_Fail_Name()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(4);

            person.Name = String.Empty;

            db.Update(person);
        }
예제 #3
0
        public void DBSalespersonTest_Update_Fail_ID()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(3);

            person.Id = -2;

            db.Update(person);
        }
예제 #4
0
        public void DBSalespersonTest_Update_Fail_LastName()
        {
            DBSalesperson db     = new DBSalesperson();
            var           person = db.Get(3);

            person.LastName = null;

            db.Update(person);
        }
예제 #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);
        }