Exemple #1
0
 public ActionResult Package(ushort?id)
 {
     if (id == null)
     {
         return(RedirectToAction("Packages"));
     }
     return(View(PackageDAO.GetById(Convert.ToUInt16(id))));
 }
Exemple #2
0
        public ActionResult Get(ushort id)
        {
            if (!Authentication.IsValid())
            {
                return(Json(new { Error = "Not Authenticated" }));
            }
            JsonResult json = Json(new { Object = PackageDAO.GetById(id) });

            json.MaxJsonLength = int.MaxValue;
            return(json);
        }
Exemple #3
0
 public Package GetById(ushort id)
 {
     return(PackageDAO.GetById(id));
 }
        public ActionResult AddItemToCart(string id, byte quantity, string type)
        {
            if (!Authentication.IsValid())
            {
                return(Json(new { Error = "Not Authenticated" }));
            }
            string name           = type == "SERVICO" ? ServiceDAO.GetById(Convert.ToUInt16(id)).Name : PackageDAO.GetById(Convert.ToUInt16(id)).Name;
            var    data           = CartDAO.GetList();
            bool   containsInCart = false;
            string view           = null;

            foreach (dynamic d in data)
            {
                if (d.Name == name)
                {
                    containsInCart = true;
                    break;
                }
            }
            CartDAO.InsertItem(name, quantity);
            if (!containsInCart)
            {
                if (type == "SERVICO")
                {
                    view = CustomHtmlHelper.CustomHtmlHelper.RenderPartialToString("Cart/_Service", new { Object = ServiceDAO.GetCartServiceByName(name) }, ControllerContext);
                }
                else
                {
                    view = CustomHtmlHelper.CustomHtmlHelper.RenderPartialToString("Cart/_Package", new { Object = PackageDAO.GetCartPackageByName(name) }, ControllerContext);
                }
            }

            JsonResult json = Json(new {
                contains     = containsInCart,
                itemQuantity = CartDAO.GetQuantity(name),
                price        = "R$ " + CartDAO.GetTotalPrice(),
                itemName     = name,
                htmlItem     = view,
                success      = "Adicionado!",
                count        = CartDAO.GetItemsCount()
            });

            json.MaxJsonLength = int.MaxValue;

            return(json);
        }