Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Login(LoginM us)
- {
- try
- {
- cuentaM account = new cuentaM();
- HttpClient client = new HttpClient();
- var result = client.GetAsync("http://localhost:26723/api/Login" + "?email=" + us.email + "&password=" + us.password).Result;
- if (result.IsSuccessStatusCode)
- {
- account = result.Content.ReadAsAsync<cuentaM>().Result;
- }
- Session["cuenta"] = account;
- return RedirectToAction("Index", "Home");
- }
- catch (Exception ex)
- {
- throw;
- }
- }
- public HttpResponseMessage Get(string email, string password)
- {
- try
- {
- using (elevationbEntities db = new elevationbEntities())
- {
- usuario user = db.usuarios.Where(m => m.email == email && m.password == password).SingleOrDefault();
- cuentaM account = new cuentaM();
- if (user != null)
- {
- account = (from o in db.cuentas
- join cu in db.cuentausuarios on o.idCuenta equals cu.idCuenta
- join u in db.usuarios on cu.idUsuario equals u.idUsuario
- where u.idUsuario == user.idUsuario
- select new cuentaM { idUsuario = user.idUsuario, idCuenta = o.idCuenta, CodigoUnico = o.CodigoUnico })
- .FirstOrDefault();
- }
- else
- {
- account.Error = "Wrong Password or Email";
- }
- HttpResponseMessage response;
- response = Request.CreateResponse(HttpStatusCode.OK, account);
- return response;
- }
- }
- catch (TaskCanceledException ex)
- {
- HttpResponseMessage response;
- response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
- return response;
- }
- }
Add Comment
Please, Sign In to add comment