예제 #1
0
        public ActionResult Edit(int?Id)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Produkt_Typ_Rohstoff_Indikator produkt = new Produkt_Typ_Rohstoff_Indikator();
            List <ProduktRohstoff>         lPRUW   = new List <ProduktRohstoff>();
            ProduktRohstoff pr  = new ProduktRohstoff();
            var             roh = _db.Rohstoffs.Select(s => s).ToList();
            var             uw  = _db.Umweltindikatorwerts.Select(s => s).ToList();

            for (int i = 0; i < roh.Count; i++)
            {
                if (roh[i].Produkt_Id == Convert.ToInt32(Id))
                {
                    pr.Rohstoff   = roh[i];
                    pr.LRohstoffe = new List <Umweltindikatorwert>();
                    for (int j = 0; j < uw.Count; j++)
                    {
                        if (roh[i].Id == uw[j].Rohstoff_Id)
                        {
                            pr.LRohstoffe.Add(uw[j]);
                        }
                    }
                    lPRUW.Add(pr);
                }
            }
            produkt = new Produkt_Typ_Rohstoff_Indikator
            {
                _Typ_Id         = _db.ProduktTyps.ToList(),
                _Produkt        = _db.Produkts.Find(Id),
                _LIndikator     = _db.Umweltindikators.ToList(),
                _Rohstoffe      = _db.Rohstoffes.ToList(),
                ProduktRohstoff = lPRUW,
                _MengeEinheit   = _db.MengeEinheits.ToList()
            };

            if (produkt._Produkt == null)
            {
                return(HttpNotFound());
            }
            return(View(produkt));
        }
예제 #2
0
        public ActionResult Create(Produkt_Typ_Rohstoff_Indikator _produktTypRohstoffIndikator = null)
        {
            Produkt_Typ_Rohstoff_Indikator viewModel = new Produkt_Typ_Rohstoff_Indikator();
            ProduktRohstoff produktRohstoff          = new ProduktRohstoff();

            produktRohstoff.LRohstoffe = new List <Umweltindikatorwert>();
            produktRohstoff.LRohstoffe.Add(new Umweltindikatorwert());
            if (_produktTypRohstoffIndikator != null)
            {
                _produktTypRohstoffIndikator.ProduktRohstoff = new List <ProduktRohstoff>();
                _produktTypRohstoffIndikator.ProduktRohstoff.Add(produktRohstoff);
                viewModel = new Produkt_Typ_Rohstoff_Indikator
                {
                    _Typ_Id         = _db.ProduktTyps.ToList(),
                    _LIndikator     = _db.Umweltindikators.ToList(),
                    _Rohstoffe      = _db.Rohstoffes.ToList(),
                    ProduktRohstoff = _produktTypRohstoffIndikator.ProduktRohstoff,
                    _MengeEinheit   = _db.MengeEinheits.ToList()
                };
            }
            return(View(viewModel));
        }