Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Web.Http;
- using System.Web.Http.Cors;
- using webService.DB;
- using webService.Models;
- namespace webService.Controllers
- {
- [EnableCors(origins: "http://localhost:8100", headers: "*", methods: "get,post")]
- public class LoginController : ApiController
- {
- [Route("api/login/GetData/{username}/{password}")]
- public HttpResponseMessage GetData(string username, string password)
- {
- using (VodovodEntities db = new VodovodEntities())
- {
- List<users> allUsers = db.users.Where(t => t.username == username.Trim() && t.password ==password.Trim()).ToList();
- if (allUsers.Count != 0)
- {
- return Request.CreateResponse(HttpStatusCode.OK, "Login succedeed.");
- }
- return Request.CreateResponse(HttpStatusCode.NotFound, "Login failed.");
- }
- }
- // POST api/values
- public void Post([FromBody]string value)
- {
- }
- // PUT api/values/5
- public void Put(int id, [FromBody]string value)
- {
- }
- // DELETE api/values/5
- public void Delete(int id)
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment