Esempio n. 1
0
        // GET: Produkt
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            Preis p = Preis.getPreis(Convert.ToInt32(id));

            if (string.IsNullOrEmpty(Session["user"] as string) || Session["role"].ToString().Equals("Gast"))
            {
                ViewBag.PreisName = "Gast Preis";
                ViewBag.Preis     = string.Format("{0:#.00}", Convert.ToDecimal(p.gastPreis));
            }
            else if (Session["role"].ToString().Equals("Student"))
            {
                ViewBag.PreisName = "Studenten Preis";
                ViewBag.Preis     = string.Format("{0:#.00}", Convert.ToDecimal(p.studentPreis));
            }
            else
            {
                ViewBag.PreisName = "Mitarbeiter Preis";
                ViewBag.Preis     = string.Format("{0:#.00}", Convert.ToDecimal(p.mitarbeiterPreis));
            }

            ViewBag.detailProdukt = Produkt.getProdukt(Convert.ToInt32(id));

            return(View());
        }
Esempio n. 2
0
        // GET: Home
        public ActionResult Index()
        {
            List <XElement> l = null;

            try
            {
                var doc = XDocument.Load(Server.MapPath("~/App_Data/Speiseplan.xml"));

                XElement root = doc.Root;

                var q = from z in root.Descendants("Menu")
                        select z;



                foreach (var v in q.Elements("Produkte").Elements("Produkt"))
                {
                    bool has = Produkt.getProdukt(Convert.ToInt32(v.Attribute("ProduktID").Value)) == null ? false: true;
                    if (!has)
                    {
                        v.Remove();
                    }
                }

                foreach (var v in q.Elements("Produkte").Elements("Produkt"))
                {
                    Produkt  produkt = Produkt.getProdukt(Convert.ToInt32(v.Attribute("ProduktID").Value));
                    Bild     bild    = Bild.getBild(produkt.BID);
                    Preis    preis   = Preis.getPreis(produkt.id);
                    XElement x       = null;
                    XElement xx      = null;

                    if (v.Parent.Parent.Attribute("Highlight") != null)
                    {
                        x = new XElement("Bild", bild.blobToBase64());
                        v.Add(x);
                    }

                    if (string.IsNullOrEmpty(Session["role"] as string) || Session["role"].ToString().Equals("Gast"))
                    {
                        x  = new XElement("preisVon", "Gast");
                        xx = new XElement("anzeigePreis", preis.gastPreis.ToString("C"));
                    }
                    else if (Session["role"].ToString().Contains("Mitarbeiter"))
                    {
                        x  = new XElement("preisVon", "Mitarbeiter");
                        xx = new XElement("anzeigePreis", preis.mitarbeiterPreis.ToString("C"));
                    }
                    else if (Session["role"].ToString().Contains("Student"))
                    {
                        x  = new XElement("preisVon", "Student");
                        xx = new XElement("anzeigePreis", preis.studentPreis.ToString("C"));
                    }
                    v.Add(x);
                    v.Add(xx);

                    x = new XElement("beschreibung", produkt.Beschreibung);
                    v.Add(x);
                    x = new XElement("titel", produkt.Name);
                    v.Add(x);
                }

                l           = q.ToList();
                ViewBag.xml = l;
            }
            catch (Exception e)
            {
            }

            return(View());
        }