Beispiel #1
0
        public IEnumerable <DilnaShort> Get(int uzivatelId, string dalsiFunkce) //dotáhne všechny dílny, které uživatel nemá ;)
        {
            var dao = new DbbDilnaDao();

            return(dao.GetAllDilnaNotWithUzival(new UzivatelDao().GetById(uzivatelId)).Select(item => new DilnaShort()
            {
                Nazev = item.Nazev,
                DilnaId = item.Id
            })
                   .ToList());
        }
        public ActionResult AddDilnaToUzivatel(int uzivatelId, int dilnaId)
        {
            var dao       = new UzivatelDao();
            var uzivatel  = dao.GetById(uzivatelId);
            var novaDilna = new DbbDilnaDao().GetById(dilnaId);

            uzivatel.DilnyUzivatelu.Add(new DilnyUzivatelu()
            {
                Dilna = novaDilna, Uzivatel = uzivatel
            });

            dao.Update(uzivatel); //tady máme chybku hele

            return(RedirectToAction("EditUzivatel", new { id = uzivatelId }));
        }