Exemplo n.º 1
0
        public IHttpActionResult Putadmin_Login(int id, admin_Login admin_Login)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != admin_Login.LoginID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult Getadmin_Login(int id)
        {
            admin_Login admin_Login = db.admin_Login.Find(id);

            if (admin_Login == null)
            {
                return(NotFound());
            }

            return(Ok(admin_Login));
        }
Exemplo n.º 3
0
        public IHttpActionResult Postadmin_Login(admin_Login admin_Login)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.admin_Login.Add(admin_Login);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = admin_Login.LoginID }, admin_Login));
        }
Exemplo n.º 4
0
        public IHttpActionResult Deleteadmin_Login(int id)
        {
            admin_Login admin_Login = db.admin_Login.Find(id);

            if (admin_Login == null)
            {
                return(NotFound());
            }

            db.admin_Login.Remove(admin_Login);
            db.SaveChanges();

            return(Ok(admin_Login));
        }
Exemplo n.º 5
0
        public ActionResult Login(admin_Login login)
        {
            if (ModelState.IsValid)
            {
                var model = (from m in db.admin_Login
                             where m.UserName == login.UserName && m.Password == login.Password
                             select m).Any();
                if (model)
                {
                    var loginInfo = db.admin_Login.Where(x => x.UserName == login.UserName && x.Password == login.Password).FirstOrDefault();

                    Session["username"] = loginInfo.UserName;
                    TemData.EmpID       = loginInfo.EmpID;
                    return(RedirectToAction("Index", "Order"));
                }
            }
            return(View("Index"));
        }
Exemplo n.º 6
0
        public ActionResult Index(admin_Login login)
        {
            if (ModelState.IsValid)
            {
                var model = (from m in db.admin_Login
                             where m.UserName == login.UserName && m.Password == login.Password
                             select m).Any();
                if (model)
                {
                    var loginInfo = db.admin_Login.Where(x => x.UserName == login.UserName && x.Password == login.Password).FirstOrDefault();

                    Session["username"] = loginInfo.UserName;
                    TemData.EmpID       = loginInfo.EmpID;
                    return(RedirectToAction("Index", "Dashboard"));
                }
                ModelState.AddModelError("", "Tài khoản hoặc mật khẩu không đúng");
            }

            return(View(login));
        }