public IHttpActionResult Post(CallViewModel call) { try { call.Create(); return(Ok(call)); } catch (Exception ex) { return(BadRequest("Create failed - " + ex.Message)); } }
public IHttpActionResult Post(CallViewModel call) { try { call.Create(); return(Ok("Call " + call.Notes + " created")); } catch (Exception ex) { return(BadRequest("Retrieve failed - " + ex.Message)); } }
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 }
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")); } }
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 }