Пример #1
0
        public IActionResult khoataikhoan(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var admin = _context.Admin.Find(id);
                if (admin.Status == true)
                {
                    admin.Status = false;
                }
                else
                {
                    admin.Status = true;
                }

                _context.Update(admin);
                _context.SaveChanges();
                string referer1 = Request.Headers["Referer"].ToString();

                return(Redirect(referer1));
            }

            return(View(NotFound()));
        }
Пример #2
0
 public IActionResult khoataikhoan(int?id)
 {
     if (id == null)
     {
         return(NotFound());
     }
     try
     {
         if (ModelState.IsValid)
         {
             var s = _context.Users.Find(id);
             if (s.Status == true)
             {
                 s.Status = false;
             }
             else
             {
                 s.Status = true;
             }
             _context.Update(s);
             _context.SaveChanges();
             return(Redirect("/admin/Users/Details/" + id));
         }
     }
     catch (Exception ex)
     {
     }
     return(View());
 }
Пример #3
0
        public IActionResult getBook(int?id)
        {
            DonHang donHang = new DonHang();
            var     xe      = _context.Xe.SingleOrDefault(x => x.Id == id);

            if (ModelState.IsValid)
            {
                donHang.MaXe     = id;
                donHang.NgayLap  = DateTime.Now;
                donHang.TuNgay   = Seacrch.ngaynhan;
                donHang.DenNgay  = Seacrch.ngaytra;
                donHang.MaUs     = CommonConstants.UserID;
                donHang.Songay   = Convert.ToInt32(Seacrch.daydiff);
                donHang.TongTien = Convert.ToInt32(Seacrch.daydiff * xe.Gia + 2500000);
                donHang.Status   = false;
                donHang.Huy      = false;

                _context.Add(donHang);
                _context.SaveChanges();

                return(RedirectToAction(nameof(CustomerOder)));
            }

            return(NotFound());
        }
Пример #4
0
        public IActionResult changeOnOff(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            try
            {
                if (ModelState.IsValid)
                {
                    var s = _context.Xe.Find(id);
                    if (s.Moban == true)
                    {
                        s.Moban = false;
                    }
                    else
                    {
                        s.Moban = true;
                    }
                    _context.Update(s);

                    _context.SaveChanges();
                }
            }
            catch
            {
            }
            return(Redirect(Request.Headers["Referer"].ToString()));
        }
Пример #5
0
        public async Task <ActionResult <ChatList> > updatems(int id, ChatList chat)
        {
            var chatlist = _context.ChatList.Find(id);

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

            else
            {
                if (chat.MyUser != chatlist.MsFrom)
                {
                    chatlist.Status = false;
                    _context.ChatList.Update(chatlist);
                    _context.SaveChanges();
                    return(Ok(chatlist));
                }
                else
                {
                    return(Ok(chatlist));
                }
            }
        }
Пример #6
0
        public IActionResult huyyeucau(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var s = _context.DonHang.Find(id);
                s.Huy = true;
                _context.DonHang.Update(s);
                _context.SaveChanges();
                string referer1 = Request.Headers["Referer"].ToString();
                return(Redirect(referer1));
            }
            return(Redirect(Request.Headers["Referer"].ToString()));
        }
Пример #7
0
        public IActionResult saveCart(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }


            var  xe = _context.Xe.SingleOrDefault(x => x.Id == id);
            Cart c  = new Cart();

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

            var cart = _context.Cart.SingleOrDefault(x => x.Maxe == id && x.Ma == CommonConstants.UserID);

            if (cart == null)
            {
                if (ModelState.IsValid)
                {
                    c.Ma          = CommonConstants.UserID;
                    c.Manguoidang = xe.MaNguoiDang;
                    c.Maxe        = xe.Id;
                    c.Gia         = xe.Gia;
                    c.Tenxe       = xe.Tenxe;
                    c.DiaChi      = xe.Diachi;
                    c.Images      = xe.Hinh;
                }
                _context.Cart.Add(c);
                _context.SaveChanges();
            }
            else
            {
                ViewData["Loi"] = "Đã lưu xe trước đó rồi";
                return(Redirect(Request.Headers["Referer"].ToString()));
            }

            string referer1 = Request.Headers["Referer"].ToString();

            return(Redirect(referer1));
        }
Пример #8
0
        public IActionResult onoffVehcle(int?id, int?khoa)
        {
            if (ModelState.IsValid)
            {
                var s = _context.Xe.Find(id);

                if (id == null)
                {
                    return(NotFound());
                }
                if (khoa != null && khoa == 1)
                {
                    s.Status = null;
                }

                else
                if (s.Status == null && khoa == 0)
                {
                    s.Status = true;
                }
                if (s.Status == true)
                {
                    s.Status = false;
                }
                else
                if (s.Status == false)
                {
                    s.Status = true;
                }
                _context.Update(s);
                _context.SaveChanges();
                string referer1 = Request.Headers["Referer"].ToString();

                return(Redirect(referer1));
            }

            return(View(NotFound()));
        }
Пример #9
0
        public IActionResult getStatus(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var s = _context.DonHang.Find(id);
                if (s.Status == true)
                {
                    s.Status = false;
                }
                else
                {
                    s.Status = true;
                }
                _context.Update(s);
                _context.SaveChanges();
                return(Redirect("/seller/oders/Details?id=" + id));
            }
            return(View());
        }