Exemplo n.º 1
0
 public ActionResult Service(ushort?id)
 {
     if (id == null)
     {
         return(RedirectToAction("Services"));
     }
     return(View(ServiceDAO.GetById(Convert.ToUInt16(id))));
 }
        public ActionResult Get(uint id)
        {
            if (!Authentication.IsValid())
            {
                return(Json(new { Error = "Not Authenticated" }));
            }
            JsonResult json = Json(new { Object = ServiceDAO.GetById(Convert.ToUInt16(id)) });

            json.MaxJsonLength = int.MaxValue;
            return(json);
        }
Exemplo n.º 3
0
        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);
        }
 public Service GetById(ushort id)
 {
     return(ServiceDAO.GetById(id));
 }
Exemplo n.º 5
0
 // GET: Service/Details/5
 public ActionResult Details(int id)
 {
     return(View(serviceDAO.GetById(id)));
 }