Пример #1
0
 public IHttpActionResult Post(CallViewModel call)
 {
     try
     {
         call.Create();
         return(Ok(call));
     }
     catch (Exception ex)
     {
         return(BadRequest("Create failed - " + ex.Message));
     }
 }
Пример #2
0
 public IHttpActionResult Post(CallViewModel call)
 {
     try
     {
         call.Create();
         return(Ok("Call " + call.Notes + " created"));
     }
     catch (Exception ex)
     {
         return(BadRequest("Retrieve failed - " + ex.Message));
     }
 }
Пример #3
0
        public void ComprehensiveVMTestsShouldReturnTrue()
        {
            CallViewModel     cvm = new CallViewModel();
            EmployeeViewModel evm = new EmployeeViewModel();
            ProblemViewModel  pvm = new ProblemViewModel();

            cvm.DateOpened = DateTime.Now;
            cvm.DateClosed = null;
            cvm.OpenStatus = true;
            evm.Lastname   = "Smartypants";
            evm.GetByLastname();
            cvm.EmployeeId = evm.Id;
            evm.Lastname   = "Burner";
            evm.GetByLastname();
            cvm.TechId      = evm.Id;
            pvm.Description = "Memory Upgrade";
            pvm.GetByProblemDescription();
            cvm.ProblemId = pvm.Id;
            cvm.Notes     = "Bigshot has bad RAM, Burner to fix it";
            cvm.Version   = 1;
            cvm.Create();
            this.tstCtx.WriteLine("New Call Generated - Id = " + cvm.Id);
            cvm.GetById();
            this.tstCtx.WriteLine("New Call Retrieved");
            cvm.Notes = "\n Ordered new RAM!";

            if (cvm.Update() == 1)
            {
                this.tstCtx.WriteLine("Call was updated " + cvm.Notes);
            }
            else
            {
                this.tstCtx.WriteLine("Call was not updated");
            }

            if (cvm.Update() == -2)
            {
                this.tstCtx.WriteLine("Call was not updated data was stale");
            }

            if (cvm.Delete() == 1)
            {
                this.tstCtx.WriteLine("Call was deleted");
            }
            else
            {
                this.tstCtx.WriteLine("Call was not deleted");
            }

            cvm.GetById(); // should throw expected exception
        }
Пример #4
0
 public IHttpActionResult Create(CallViewModel call)
 {
     try
     {
         call.Create();
         if (call.Id != "")
         {
             return(Ok("Ok! Call Created!"));
         }
         else
         {
             return(Ok("Error! Call could not be created"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest("Update Failed - Contact Tech Support"));
     }
 }
Пример #5
0
        public void CallViewModelComprehensiveTestsReturnTrue()
        {
            CallViewModel vm = new CallViewModel();

            vm.DateOpened = DateTime.Now;
            vm.OpenStatus = true;
            vm.EmployeeId = "56464e723dd4df30e88b8b8c"; // Bigshot
            vm.TechId     = "56464e723dd4df30e88b8b92"; //Burner
            vm.ProblemId  = "56464e723dd4df30e88b8b99";
            vm.Notes      = "Bigshot has bad RAM, Burner to fix it";
            vm.Create();
            this.testContextInstance.WriteLine("New Call Id == " + vm.Id);
            vm.GetByID(vm.Id);
            this.testContextInstance.WriteLine("Call retrieved");
            vm.Notes = vm.Notes + "\nOrdered new Ram";

            if (vm.Update() == 1)
            {
                this.testContextInstance.WriteLine("Call was updated " + vm.Notes);
            }
            else
            {
                Trace.WriteLine("Call was not updated");
            }

            if (vm.Delete())
            {
                this.testContextInstance.WriteLine("Call was deleted");
            }
            else
            {
                this.testContextInstance.WriteLine("Call was not deleted");
            }

            vm.Update(); //should throw MongoException see attribute
        }