Пример #1
0
        public ActionResult DetailSubUkolHistory(int id)
        {
            var lopHist = new SubUkolHistoryDao().GetById(id); //natáhneme historii a pošleme i s jejím lopem

            return(View(new SubUkolHistoryVsSubUkol(lopHist, new SubUkolDao().GetById(lopHist.SubUkol.Id))));
        }
Пример #2
0
        public ActionResult EditSubUkol(int id, SubUkol collection, bool poslatMailResiteli, bool poslatMailZadavateli)
        {
            var history = TempData["LopSubUkolHistory"] as SubUkol;

            if (history == null)
            {
                return(RedirectToAction("Index"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    //TEST SHODNOTI
                    if (collection.IsSame(history)) //vrací FALSE, pokud nastala změna
                    {
                        TempData[MessagesHelper.Info] = Resources.LopTexts.NebylyProvedenyZadneZmeny;
                        return(RedirectToAction("Edit", new { id = collection.Lop.Id }));
                    }

                    //ZMĚNA? - ULOŽÍME DO HISTORIE A PŘEPÍŠEME
                    var subUkolDao     = new SubUkolDao();
                    var subUkolHistDao = new SubUkolHistoryDao();

                    /*
                     * //uložení historie
                     * var copy = new SubUkolHistory(history);
                     * subUkolHistDao.Create(copy);
                     */
                    //update objektu
                    collection.LastChangedDate = DateTime.Now;

                    subUkolDao.Update(collection);

                    TempData[MessagesHelper.Success] = Resources.LopTexts.ZmenyUspesneUlozeny;

                    //NOTIFIKACE
                    if (poslatMailResiteli)
                    {
                        string s = Resources.LopTexts.BylUpravenLop +
                                   " <a href='/LOP/DetailSubUkol/" + collection.Id + "?showHistory=true#historyBtn'>" + collection.Nazev + "</a>";
                        Notifikace.Create(collection.Resitel.Id, s);
                    }
                    if (poslatMailZadavateli)
                    {
                        string s = Resources.LopTexts.BylUpravenLop +
                                   " <a href='/LOP/DetailSubUkol/" + collection.Id + "?showHistory=true#historyBtn'>" + collection.Nazev + "</a>";
                        Notifikace.Create(collection.Zadavatel.Id, s);
                    }

                    return(Redirect(Url.RouteUrl(new { controller = "Lop", action = "DetailSubUkol", id = collection.Id, showHistory = true }) + "#historyBtn"));

                    //return RedirectToAction("DetailSubUkol", new {id = collection.Id});
                }
                TempData[MessagesHelper.Warning] = Resources.LopTexts.ZkontrolujteZadaneUdaje;
            }
            catch
            {
                TempData[MessagesHelper.Danger] = Resources.LopTexts.DosloKNeocekavaneChybe;
            }

            TempData["LopSubUkolHistory"] = history;
            return(View(collection));
        }