public HttpResponseMessage Login([FromBody] Worker worker) { Worker w = HomeLogic.Login(worker.UserName, worker.Password); if (w != null) { return new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <Worker>(w, new JsonMediaTypeFormatter()) } } ; else { return new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <String>("Can not log in", new JsonMediaTypeFormatter()) } }; }