Exemplo n.º 1
0
 public IHttpActionResult PostLogin(Login LogData)
 {
     Login login = new Login();
     login = db.Logins.Where(i => i.Password == LogData.Email && i.Password == LogData.Password).FirstOrDefault();
     //foreach (var item in db.Logins)
     //{
     //    if ((item.Email == LogData.Email) && (item.Password == LogData.Password))
     //    {
     //        login.RolesId = item.RolesId;
     //        break;
     //    }
     //}
     Login login2 = new Login();
     login2.Name = login.Name;
     login2.RolesId = login.RolesId;
     return Ok(login2);
 }
Exemplo n.º 2
0
        public IHttpActionResult PutLogin(int id, Login login)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != login.Id)
            {
                return BadRequest();
            }

            db.Entry(login).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoginExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 3
0
        public IHttpActionResult PostRegistration(Login login)
        {
            string error = "";
            Login log = new Login();
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            //log = db.Logins.Where(i => i.Email == login.Email).FirstOrDefault();
            //if (log != null)
            //{
            //    error = "This Email is not valid";
            //    return Ok(error);
            //}
            //else
            //{
            db.Logins.Add(login);

            //}

            //foreach (var item in db.Logins)
            //{
            //    if (item.Email != login.Email)
            //    {
            //        db.Logins.Add(login);
            //    }
            //    else
            //    {
            //        error = "This Email is not valid";
            //        return Ok(error);

            //    }

            //}
            db.SaveChanges();
            return CreatedAtRoute("DefaultApi", new { id = login.Id }, login);
        }