Exemplo n.º 1
0
        public void AddLetter(Letter letter)
        {
            db_mysql db_mysql = new db_mysql();

            if (letter.Id == 0)
            {
                letter last_letter = db_mysql.letters.OrderByDescending(u => u.Id).FirstOrDefault();
                letter.Id = last_letter.Id + 1;
            }

            letter new_letter = Mapper.Map<Letter, letter>(letter);
            db_mysql.letters.Add(new_letter);
            db_mysql.SaveChanges();
        }
Exemplo n.º 2
0
        public void AddComment(Comment comment, Letter letter)
        {
            letter transposed = Mapper.Map<Letter, letter>(letter);

            db_mysql db_mysql = new db_mysql();
            db_mysql.letters.Attach(transposed);
            var letter_obj = db_mysql.Entry(transposed);

            if (comment.level > -1)
            {
                letter_obj.Property(e => e.letterComments).IsModified = true;
                transposed.letterComments = transposed.letterComments + 1;
            }

            db_mysql.comments.Add(Mapper.Map<Comment, comment>(comment));
            db_mysql.SaveChanges();
        }
Exemplo n.º 3
0
        public ActionResult Contact(Core.Model.Contact msg)
        {
            String userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null || userip == "127.0.0.1")
                userip = Request.ServerVariables["REMOTE_ADDR"];

            msg.Message = "Feedback received ( " + msg.Email + " ): <br /><br />" + msg.Message + "<br><br>sent from ip: " + userip;

            _mailService.SendContact(msg.Message, msg.Email);

            Letter contact_letter = new Letter();
            contact_letter.letterLanguage = "en-US";
            contact_letter.letterLevel = -10;
            contact_letter.letterPostDate = DateTime.UtcNow;
            contact_letter.senderIP = userip;
            contact_letter.letterMessage = msg.Message;
            contact_letter.letterComments = 0;
            contact_letter.letterUp = 1;

            _letterService.AddLetter(contact_letter);

            return View("Thanks");
        }
Exemplo n.º 4
0
        public JsonResult Vote(int id, string c = "")
        {
            string userip = null;
            userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null)
                userip = Request.ServerVariables["REMOTE_ADDR"];

            string signalr_hub = "http://*****:*****@gmail.com";

                string hub_state = "";
                if (hubConnection != null)
                {
                    hub_state = hubConnection.State.ToString();
                }
                else
                {
                    hub_state = "null";
                }
                msg.Message = "state: " + hub_state + "<br><br>" + ex.Message.ToString();
                if (ex.InnerException != null)
                {
                    msg.Message = msg.Message + "<br><br>" + ex.InnerException.Message.ToString();
                }

                _mailService.SendContact(msg.Message, msg.Email);

            }

            return Json(letter, JsonRequestBehavior.AllowGet);
        }