예제 #1
0
 //Add Call function
 public void Add()
 {
     Id = -1;
     try
     {
         // Create a new Call object and add the properties
         // from the object that has called the Add() function
         Call call = new Call();
         call.EmployeeId = EmployeeId;
         call.ProblemId  = ProblemId;
         call.TechId     = TechId;
         call.DateOpened = DateOpened;
         call.OpenStatus = OpenStatus;
         call.DateClosed = DateClosed;
         call.Notes      = Notes;
         //call.Timer = Convert.FromBase64String(Timer);
         Id    = _model.Add(call);
         Timer = Convert.ToBase64String(call.Timer);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Problem in " + GetType().Name + " " +
                           MethodBase.GetCurrentMethod().Name + " " + ex.Message);
         throw ex;
     }
 }
예제 #2
0
        public void Call_ComprehensiveTest()
        {
            CallModel     cmodel = new CallModel();
            EmployeeModel emodel = new EmployeeModel();
            ProblemModel  pmodel = new ProblemModel();
            Calls         call   = new Calls();

            call.DateOpened = DateTime.Now;
            //call.DateClosed = null;
            call.OpenStatus = true;
            call.EmployeeId = emodel.GetByLastname("Park").Id;
            call.TechId     = emodel.GetByLastname("Burner").Id;
            call.ProblemId  = pmodel.GetByDescription("Hard Drive Failure").Id;
            call.Notes      = "Jimin's drive is shot, Burner to fix it";

            int newCallId = cmodel.Add(call);

            output.WriteLine("New Call Generated - Id = " + newCallId);
            call = cmodel.GetById(newCallId);
            byte[] oldtimer = call.Timer;
            output.WriteLine("New Call Retrieved");
            call.Notes += "\n Ordered new drive!";

            if (cmodel.Update(call) == UpdateStatus.Ok)
            {
                output.WriteLine("Call was updated " + call.Notes);
            }
            else
            {
                output.WriteLine("Call was not updated!");
            }

            call.Timer = oldtimer;
            call.Notes = "doesn't matter data is stale now";
            if (cmodel.Update(call) == UpdateStatus.Stale)
            {
                output.WriteLine("Call was not updated due to stale data");
            }

            cmodel = new CallModel();
            call   = cmodel.GetById(newCallId);

            if (cmodel.Delete(newCallId) == 1)
            {
                output.WriteLine("Call was deleted!");
            }
            else
            {
                output.WriteLine("Call was noe deleted");
            }
            Assert.Null(cmodel.GetById(newCallId));
        }
예제 #3
0
        public void ComprehensiveModelTestsShouldReturnTrue()
        {
            CallModel     cmodel = new CallModel();
            EmployeeModel emodel = new EmployeeModel();
            ProblemModel  pmodel = new ProblemModel();
            Call          call   = new Call();

            call.DateOpened = DateTime.Now;
            call.DateClosed = null;
            call.OpenStatus = true;
            call.EmployeeId = emodel.GetByLastname("Jarocki").Id;
            call.TechId     = emodel.GetByLastname("Burner").Id;
            call.ProblemId  = pmodel.GetByDescription("Hard Drive Failure").Id;
            call.Notes      = "Kevin's drive is shot, Burner to fix it";
            int newCallId = cmodel.Add(call);

            Console.WriteLine("New Call Generated - Id = " + newCallId);
            call = cmodel.GetById(newCallId);
            byte[] oldtimer = call.Timer;
            Console.WriteLine("New Call Retrieved");
            call.Notes += "\n Ordered new RAM!";

            if (cmodel.Update(call) == UpdateStatus.Ok)
            {
                Console.WriteLine("Call was updated " + call.Notes);
            }
            else
            {
                Console.WriteLine("Call was not updated!");
            }

            call.Timer = oldtimer;
            if (cmodel.Update(call) == UpdateStatus.Stale)
            {
                Console.WriteLine("Call was not updated due to stale data");
            }
            cmodel = new CallModel();
            call   = cmodel.GetById(newCallId);

            if (cmodel.Delete(newCallId) == 1)
            {
                Console.WriteLine("call was deleted!");
            }
            else
            {
                Console.WriteLine("call was not deleted");
            }

            Assert.IsNull(cmodel.GetById(newCallId));
        }
예제 #4
0
 //Add an call
 public void Add()
 {
     Id = -1;
     try
     {
         Call ca = new Call();
         ca.EmployeeId = EmployeeId;
         ca.TechId     = TechId;
         ca.ProblemId  = ProblemId;
         ca.OpenStatus = OpenStatus;
         ca.Notes      = Notes;
         ca.DateOpened = DateOpened;
         ca.DateClosed = DateClosed;
         Id            = _model.Add(ca);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
         throw ex;
     }
 }
예제 #5
0
        }//end getAll

        //Add a call
        public void Add()
        {
            Id = -1;
            try
            {
                //Create a call object from the attributes of the view model object that this methid is called on
                Call call = new Call();
                call.EmployeeId = EmployeeId;
                call.ProblemId  = ProblemId;
                call.TechId     = TechId;
                call.DateOpened = DateOpened;
                call.DateClosed = DateClosed;
                call.OpenStatus = OpenStatus;
                call.Notes      = Notes;

                //use the call model's add method to add the call into the database
                Id = _model.Add(call);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }
        }