Beispiel #1
0
        // GET: GioSach
        public ActionResult ThemSach(string madausach, string urlnext)
        {
            if (Session["role"].ToString() == "u")
            {
                return(Redirect("/DangNhap/NhapThongTin"));
            }
            if (Session["role"].ToString() == "ma" || Session["role"].ToString() == "a")
            {
                return(Redirect(urlnext));
            }
            Sach_DTO dausach = Sach_BUS.LayThongTinChiTietCuaDauSachBoiMa(madausach);

            if (dausach != null)
            {
                bool cotontai = false;
                foreach (Item_DTO item in (List <Item_DTO>)Session["items"])
                {
                    if (item.Madausach == dausach.Madausach)
                    {
                        item.Soluong = item.Soluong + 1;
                        cotontai     = true;
                    }
                }
                if (cotontai == false)
                {
                    Item_DTO item = new Item_DTO();
                    item.Madausach = dausach.Madausach;
                    item.Tensach   = dausach.Tensach;
                    item.Bia       = dausach.Bia;
                    item.Soluong   = 1;
                    ((List <Item_DTO>)Session["items"]).Add(item);
                }
            }
            return(Redirect(urlnext));
        }