Ejemplo n.º 1
0
        public void SendLogin()
        {
            try
            {
                LoginGetDTO loginGetDTO = loginDAO.Login(LoginSendDTO);

                //Añadir Perfil obtenido del Servidor en la base de datos local
                Profile p = new Profile(loginGetDTO.Profile.Username, loginGetDTO.Profile.Name, loginGetDTO.Profile.Email, loginGetDTO.Profile.Phone, loginGetDTO.Profile.TOKEN);
                profileDAO.Insert(p);

                //Añadir Contactos obtenidos del Servidor en la base de datos local
                foreach (ContactSERVER contactSERVER in loginGetDTO.Contacts)
                {
                    Contact c = new Contact(contactSERVER.ContactID, contactSERVER.Username, contactSERVER.Name);
                    contactDAO.Insert(c);
                }

                //Añadir Chats obtenidos del Servidor en la base de datos local

                foreach (ChatSERVER chatSERVER in loginGetDTO.Chats)
                {
                    Chat c = new Chat(chatSERVER.ChatID, chatSERVER.ContactID, chatSERVER.Username, chatSERVER.Name);
                    chatDAO.Insert(c);
                }
            }
            catch (MyException e)
            {
                throw e;
            }
        }
Ejemplo n.º 2
0
        public ActionResult Contact(MESSAGE contact)
        {
            var sessionUser = Session[Common.CommonConstants.USER_SESSION];

            if (ModelState.IsValid)
            {
                string content = System.IO.File.ReadAllText(Server.MapPath("~/Views/Home/MessageEmail.html"));

                content = content.Replace("{{CustomerName}}", contact.Name);
                content = content.Replace("{{Email}}", contact.Email);
                content = content.Replace("{{Title}}", contact.Title);
                content = content.Replace("{{Message}}", contact.Message_Content);

                //var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();

                //new MailHelper().SendMail(toEmail, contact.Title, content);

                ContactDAO contactDAO = new ContactDAO();

                var result = contactDAO.Insert(contact);

                if (result > 0)
                {
                    return(Json(new { result = true, data = PartialViewToString("ContactForm", new MESSAGE()) }));
                }
                else
                {
                    ModelState.AddModelError("", "Đã xảy ra lỗi, gửi không thành công!");
                }
            }
            return(PartialView("ContactForm", contact));
        }
Ejemplo n.º 3
0
 public void refresh()
 {
     if (this.profileDAO.GetValue() == null)
     {
         return;
     }
     ContactList.Clear();
     foreach (ContactSERVER contactSERVER in contactDAO_SERVER.refresh(new TokenSendDTO(this.profileDAO.GetValue().Token)).Contacts)
     {
         Contact c = new Contact(contactSERVER.ContactID, contactSERVER.Username, contactSERVER.Name);
         contactDAO.Insert(c);
         ContactList.Add(c);
     }
 }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            Contact c = new Contact();

            c.FirstName   = txtFirstName.Text.Trim();
            c.LastName    = txtLastName.Text.Trim();
            c.Email       = txtEmail.Text.Trim();
            c.PhoneNumber = txtPhone.Text.Trim();
            c.Title       = txtTitle.Text.Trim();
            c.Content     = txtContent.Text.Trim();
            if (ContactDAO.Insert(c))
            {
                lblSuccess.Visible = true;
                lblSuccess.Text    = "Send Successfully!";
            }
        }
        public ActionResult ThemMoi(Contact entity)
        {
            if (ModelState.IsValid)
            {
                var dao = new ContactDAO();

                var result = dao.Insert(entity);
                if (result)
                {
                    SetAlert("Thêm liên hệ thành công", "success");
                    return(RedirectToAction("Index", "TrangLienHe"));
                }
                else
                {
                    SetAlert("Thêm liên hệ không thành công", "error");
                    return(RedirectToAction("ThemMoi", "TrangLienHe"));
                }
            }
            return(View("Index"));
        }
        public ActionResult Create(Contact lh)
        {
            if (ModelState.IsValid)
            {
                var dao = new ContactDAO();

                long id = dao.Insert(lh);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "HomeClient"));
                }
                else
                {
                    ModelState.AddModelError("", "Liên hệ thất bại");
                }
            }

            var listNews = new NewsDAO().ListAll();

            ViewBag.New = listNews;

            return(View());
        }