public IHttpActionResult Get(string Id) { try { CallViewModel call = new CallViewModel(); call.Id = Id; call.GetByID(Id); return(Ok(call)); } catch (Exception ex) { return(BadRequest("Retrieve failed - " + ex.Message)); } }
public IHttpActionResult Delete(string Id) { try { CallViewModel call = new CallViewModel(); call.Id = Id; call.GetByID(Id); call.Delete(); return(Ok("Call deleted!")); } catch (Exception ex) { return(BadRequest("Update failed - " + ex.Message)); } }
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 }