Ejemplo n.º 1
0
        public ActionResult CreateSubUkol(int lopId)
        {
            var item = new SubUkol
            {
                Action    = 1,
                LopId     = lopId,
                Zadavatel = new Uzivatel(User.Identity.Name)
            }; //naplnění lopu a akce

            ViewBag.FirstCreate = true;
            return(View(item));
        }
Ejemplo n.º 2
0
        public ActionResult CreateSubUkol(SubUkol collection, bool poslatMail)
        {
            ViewBag.FirstCreate = false;
            try
            {
                if (ModelState.IsValid)
                {
                    SubUkolDao sDao = new SubUkolDao();

                    collection.StartDate       = DateTime.Now;
                    collection.LastChangedDate = DateTime.Now;
                    collection.Status          = StatusUkolu.Open;
                    var latest = sDao.GetLatestSubUkolThisYear();
                    collection.Action = latest?.Action + 1 ?? 1;
                    collection.Id     = (int)sDao.Create(collection);
                    TempData[MessagesHelper.Success] = Resources.LopTexts.PodukolPridany;
                    //posíláme vždy
                    //if (poslatMail)
                    var s = Resources.LopTexts.BylVamPridelenNovyPodukol +
                            " <a href='/Lop/DetailSubUkol/" + collection.Id + "'>" + collection.Nazev + "</a>";
                    Notifikace.Create(collection.Resitel.Id, s);
                }
                else
                {
                    TempData[MessagesHelper.Warning] = Resources.LopTexts.ZkontrolujteZadaneUdaje;
                    return(View(collection));
                }
            }
            catch
            {
                TempData[MessagesHelper.Warning] = Resources.LopTexts.DosloKNeocekavaneChybe;
                return(View(collection));
            }


            return(RedirectToAction("DetailSubUkol", new { id = collection.Id }));
        }
Ejemplo n.º 3
0
        public ActionResult DenySubUkol(int id, string deniedMessage)
        {
            try
            {
                SubUkolDao subDao = new SubUkolDao();
                SubUkol    su     = subDao.GetById(id);

                /*
                 * //uložení historie
                 * var histDao = new SubUkolHistoryDao();
                 * var copy = new SubUkolHistory(su);
                 * histDao.Create(copy);
                 */

                su.LastChangedDate = DateTime.Now; //něco se děje
                su.DeniedMessage   = deniedMessage;

                //update objektu
                subDao.Update(su);

                var s = su.Resitel + " " + Resources.LopTexts.OdmitlResitPodukol + " " +
                        "<a href='/Lop/DetailSubUkol/" + su.Id + "'>" + su.Nazev +
                        "</a><br />" + su.DeniedMessage;
                Notifikace.Create(su.Zadavatel.Id, s);

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

                return(RedirectToAction("Detail", new { su.Lop.Id }));
            }
            catch
            {
                TempData[MessagesHelper.Warning] = Resources.LopTexts.NepodariloSeOdmitnoutPodukol;
            }

            return(RedirectToAction("SubUkolDetail/" + id));
        }
Ejemplo n.º 4
0
        public ActionResult FinishSubukol(int id, bool finished, string komentar, bool?backToLopDetail)
        {
            try
            {
                SubUkolDao subDao = new SubUkolDao();
                SubUkol    su     = subDao.GetById(id);

                su.LastChangedDate = DateTime.Now; //něco se děje

                if (finished)
                {/*
                  * //uložení historie
                  * var histDao = new SubUkolHistoryDao();
                  * var copy = new SubUkolHistory(su);
                  * histDao.Create(copy);
                  */
                    Uzivatel u           = new UzivatelDao().GetByWindowsId(User.Identity.Name.ToUpper());
                    bool     isZadavatel = u.Id == su.Zadavatel.Id;

                    if (isZadavatel && su.Status == StatusUkolu.Closed)
                    {
                        su.CheckDate  = DateTime.Now; //proběhla kontrola (ať už jakákoliv)
                        su.FinishDate = DateTime.Now; //v pořádku
                    }
                    else
                    {
                        su.CloseDate = DateTime.Now;
                    }

                    su.Status = StatusUkolu.Closed; //řešitel pouze uzavírá na close

                    if (!string.IsNullOrEmpty(komentar))
                    {
                        var koment = komentar + "<br />";
                        koment     += $"<span class=\"glyphicon glyphicon-time\"></span><i>{DateTime.Now} - by {new Uzivatel(User.Identity.Name)}</i>";
                        su.Komentar = (!string.IsNullOrEmpty(su.Komentar) ? su.Komentar + "<hr />" + koment : koment);
                    }



                    //update objektu
                    subDao.Update(su);

                    if (isZadavatel)
                    {
                        string s = Resources.LopTexts.ByloPrijatoReseniPodukolu +
                                   " <a href='/Lop/DetailSubUkol/" + su.Id + "?showHistory=true#historyBtn'>" + su.Nazev +
                                   "</a>";
                        Notifikace.Create(su.Resitel.Id, s);
                    }
                    else
                    {
                        string s = Resources.LopTexts.PodukolBylOznacenJakoVyreseny +
                                   " <a href='/Lop/DetailSubUkol/" + su.Id + "'>" + su.Nazev + "</a>";
                        Notifikace.Create(su.Zadavatel.Id, s);
                    }


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

                    if (backToLopDetail != null && backToLopDetail == true)
                    {
                        return(RedirectToAction("Detail/" + su.Lop.Id));
                    }
                }
                else
                {                                     /*
                                                       * // uložení historie
                                                       * var histDao = new SubUkolHistoryDao();
                                                       * var copy = new SubUkolHistory(su);
                                                       * histDao.Create(copy);
                                                       */
                    //pokud chceme označit jako nevyřešený
                    su.CheckDate  = DateTime.Now;     //proběhla kontrola (ať už jakákoliv)
                    su.CloseDate  = null;
                    su.FinishDate = null;             //nepřijato
                    su.Status     = StatusUkolu.Open; //úkol musí být dále zpracováván

                    if (!string.IsNullOrEmpty(komentar))
                    {
                        var koment = komentar + "<br />";
                        koment     += $"<span class=\"glyphicon glyphicon-time\"></span><i>{DateTime.Now} - by {new Uzivatel(User.Identity.Name)}</i>";
                        su.Komentar = (!string.IsNullOrEmpty(su.Komentar) ? su.Komentar + "<hr />" + koment : koment);
                    }


                    subDao.Update(su);

                    //update objektu
                    string s = Resources.LopTexts.ByloOdmitnutoReseniPodukolu +
                               " <a href='/Lop/DetailSubUkol/" + su.Id + "?showHistory=true#historyBtn'>" + su.Nazev + "</a>";
                    Notifikace.Create(su.Resitel.Id, s);


                    TempData[MessagesHelper.Warning] = Resources.LopTexts.PodukolJeZnovuVReseni;

                    if (backToLopDetail != null && backToLopDetail == true)
                    {
                        return(RedirectToAction("Detail/" + su.Lop.Id));
                    }
                }
            }
            catch
            {
                TempData[MessagesHelper.Warning] = Resources.LopTexts.NepodariloSeUpravitZaznam;
            }

            return(RedirectToAction("DetailSubUkol/" + id));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
 public SubUkolHistoryVsSubUkol(SubUkolHistory lh, SubUkol l)
 {
     this.LH = lh;
     this.L  = l;
 }