public JsonResult IspratiPorakaOdWS(Poraki poraka)
        {
            var user = (LoggedInEntity)Session["LoggedInEntity"];
            poraka.Date = DateTime.Now;
            poraka.IsSent = false;
            poraka.IsDeleted = false;
            poraka.IsReceived = true;

            if (user.UserType == Helpers.Enumerations.LogedUserTypeEnum.Poedinec)
                poraka.IdPoedinci = user.Id;
            else
                poraka.IdKompanii = user.Id;

            model.SocuvajPoraka(poraka);
            return Json(new { Status = "Success" });
        }
Example #2
0
 public void SocuvajPoraka(Poraki poraka)
 {
     _db.Poraki.Add(poraka);
     _db.SaveChanges();
 }
Example #3
0
        public void IspratiISnimiPoraka(Poraki poraka)
        {
            string mailUser = "******";
            string mailUserPwd = "applicationClientsPass";
            SmtpClient client = new SmtpClient("smtp.gmail.com");
            client.Port = 587;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(mailUser, mailUserPwd);
            client.EnableSsl = true;
            client.Credentials = credentials;

            foreach (Klienti klient in poraka.Klienti)
            {
                MailMessage mail = new MailMessage(mailUser, klient.Mail);
                mail.Subject = poraka.Subject;
                mail.Body = poraka.Body;
                try
                {
                    client.Send(mail);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            SocuvajPoraka(poraka);
        }
Example #4
0
        public ActionResult SocuvajPoraka(ViewPoraki vporaka, int[] selectedKlients)
        {
            var user = (LoggedInEntity)Session["LoggedInEntity"];

            Poraki novaPoraka = new Poraki();
            novaPoraka.Subject = vporaka.Subject;
            novaPoraka.Body = vporaka.Body;
            novaPoraka.Date = DateTime.Now;
            novaPoraka.IsSent = false;
            novaPoraka.IsDeleted = false;
            novaPoraka.IsReceived = false;
            novaPoraka.Klienti = _klienti.ListaNaKlientiSporedId(selectedKlients);

            if (user.UserType == Helpers.Enumerations.LogedUserTypeEnum.Poedinec)
                novaPoraka.IdPoedinci = user.Id;
            else
                novaPoraka.IdKompanii = user.Id;

            _poraki.SocuvajPoraka(novaPoraka);
            return RedirectToAction("Index");
        }