public HttpResponseMessage Put(int id, Agent agent) { var successAPIResult = new SuccessAPIResult() { Usage = "HttpPut:~/api/Agent/{id} with Agent json in body" }; successAPIResult.Successful = AgentBusinessLayer.UpdateAgent(id, agent); if (!successAPIResult.Successful) { return(Request.CreateResponse(HttpStatusCode.NotFound, successAPIResult)); } return(Request.CreateResponse(HttpStatusCode.OK, successAPIResult)); }
public HttpResponseMessage Get(int id) { var agentAPIResult = new AgentAPIResult() { Usage = "HttpGet:~/api/Agent/{id} or {args} can be on querystring, {args?} are optional" }; agentAPIResult.Agent = AgentBusinessLayer.GetAgent(id); if (agentAPIResult.Agent == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, agentAPIResult)); } return(Request.CreateResponse(HttpStatusCode.OK, agentAPIResult)); }
protected void Application_Start() { var initDB = false; GlobalConfiguration.Configure(WebApiConfig.Register); CustomerBusinessLayer.Register(new DBLayer()); AgentBusinessLayer.Register(new DBLayer()); bool.TryParse(ConfigurationManager.AppSettings["InitDB"], out initDB); if (initDB) { InitDB(); } }
public void WillCallDBLayerOnceWhenCreate() { AgentBusinessLayer.CreateAgent(new Agent()); mockDBLayer.Verify(m => m.CreateEntity <Agent>(It.IsAny <Agent>()), Times.Once); }
public void WillCallDBLayerOnceWhenGetAll() { AgentBusinessLayer.GetAgents(1, 1); mockDBLayer.Verify(m => m.FindAllEnties <Agent>(It.IsAny <int>(), It.IsAny <int>()), Times.Once); }
public void WillCallDBLayerOnceWhenUpdate() { AgentBusinessLayer.UpdateAgent(1, new Agent()); mockDBLayer.Verify(m => m.UpdateEntity <Agent>(It.IsAny <Agent>(), It.IsAny <int>()), Times.Once); }
public void WillCallDBLayerOnceWhenGetById() { AgentBusinessLayer.GetAgent(1); mockDBLayer.Verify(m => m.FindEntity <Agent>(It.IsAny <int>()), Times.Once); }
public void WillThrowExpectedExceptionWhenRegisteringNullDBLayer() { AgentBusinessLayer.Register(null); }
public void Init() { mockDBLayer = new Mock <IDBLayer>(); AgentBusinessLayer.Register(mockDBLayer.Object); }