public IHttpActionResult CreateNewNetwork([FromBody] Network item)
        {
            repo = new NetworkDatabaseRepository();
            Network networkToReturn = repo.CreateNewNetwork(item);

            return(Content <Network>(HttpStatusCode.Created, networkToReturn));
        }
Exemplo n.º 2
0
        public IHttpActionResult DeleteUser(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Not a valid user id"));
            }

            repo = new NetworkDatabaseRepository();
            repo.DeleteUser(id);
            repo.DeleteUsersNetwork(id);
            return(Ok());
        }
        public IHttpActionResult GiveMeNetwork(string name, string pass)
        {
            var repo            = new NetworkDatabaseRepository();
            var networkToReturn = repo.GetNetworkByName(name, pass);

            if (networkToReturn != null)
            {
                return(Content <Network>(HttpStatusCode.Found, networkToReturn));
            }
            else
            {
                return(Content <Network>(HttpStatusCode.NotFound, null));
            }
        }
Exemplo n.º 4
0
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            var us = new User()
            {
                Name = "test1",
                //UserId = 23440984,
                NetworkId = 10
            };

            repo = new NetworkDatabaseRepository();
            var userToReturn = repo.CreateNewUser(us);

            return(Content <User>(HttpStatusCode.OK, us));
        }
Exemplo n.º 5
0
        public IHttpActionResult CreateNewUser([FromBody] User user)
        {
            repo = new NetworkDatabaseRepository();
            var userToReturn = repo.CreateNewUser(user);

            //var responseMessage = new HttpResponseMessage();
            //responseMessage.StatusCode = HttpStatusCode.Created;
            return(Content <User>(HttpStatusCode.Created, userToReturn));
            //return Content<string>(HttpStatusCode.Created,"fdgdhffghfgjhfgjfgkkfghndyjutjmnghjgjghjg");
            //return Ok<User>(userToReturn);
            //return Ok<string>($"{userToReturn.UserId} some huuuuge message and bla-bla-bla");

            //var message = Request.CreateResponse(HttpStatusCode.Created, userToReturn);
            //message.Headers.Location = new Uri(Request.RequestUri + userToReturn.UserId.ToString());
            //return message;
        }