Exemplo n.º 1
0
        public void Post(Pozadavek value)
        {
            var dao = new NotifikaceDao();

            if (value.Typ == "Submit")
            {
                var item = dao.GetById(value.Id);
                item.Seen = true;
                dao.Update(item);
            }
        }
Exemplo n.º 2
0
        // GET: Notifikace
        public ActionResult Index()
        {
            if (!Uzivatel.UserExists(User.Identity.Name))
            {
                TempData[MessagesHelper.Info] = Resources.HomeTexts.NotAuthorized;
                return(RedirectToAction("About", "Home"));
            }
            var dao  = new NotifikaceDao();
            var nove = dao.GetByUser(new Uzivatel(User.Identity.Name), false);
            var seen = dao.GetByUser(new Uzivatel(User.Identity.Name));

            ViewBag.nove = nove;
            ViewBag.seen = seen;

            return(View());
        }
Exemplo n.º 3
0
        public static int Create(int userId, string text)
        {
#if DEBUG
#else
            text = text.Replace("<a href=\"", "<a href=\"" + AppUrl);
            text = text.Replace("<a href='", "<a href='" + AppUrl);
#endif

            var dao        = new NotifikaceDao();
            var uzivatel   = new UzivatelDao().GetById(userId);
            var notifikace = new Notifikace()
            {
                Uzivatel = uzivatel,
                Text     = text,
                Created  = DateTime.Now,
                Seen     = false
            };
            notifikace.Id = (int)dao.Create(notifikace);

            if (string.IsNullOrEmpty(uzivatel.Email))
            {
                return(notifikace.Id);
            }


            var email = new Email
            {
                Subject = "Nové upozornění",
                Body    = text
            };
            email.AddMailToAddress(uzivatel.Email);
#if DEBUG
#else
            try{
                email.Send();
            }
            catch
            {
                // ignored
            }
#endif


            return(notifikace.Id);
        }