Exemplo n.º 1
0
        public ActionResult Index()
        {
            VMContact model = new VMContact();

            model.Contact = db.Contacts.FirstOrDefault();
            model.BGImage = db.BGImages.FirstOrDefault(b => b.Page == "Contact");
            return(View(model));
        }
        public IActionResult Contact()
        {
            VMContact model = new VMContact()
            {
                Settings = _context.Settings.First()
            };

            return(View(model));
        }
        public JsonResult Message(VMContact model)
        {
            if (string.IsNullOrEmpty(model.Name)
                ||
                string.IsNullOrEmpty(model.Phone)
                ||
                string.IsNullOrEmpty(model.Email)
                ||
                string.IsNullOrEmpty(model.Subject)
                ||
                string.IsNullOrEmpty(model.Message))
            {
                Response.StatusCode = 406;
                return(Json("Bütün xanalar doldurulmalıdır"));
            }

            var body = "<ul>" +
                       "<li>Ad : {0}</li>" +
                       "<li>E-poçt: {1}</li>" +
                       "<li>Mesajın başlığı : {3}</li>" +
                       "<li>Mesaj : {2}</li>" +
                       "<li>Əlaqə nömrəsi : {4}</li>" +
                       "</ul>";
            var MailMessage = new MailMessage();

            MailMessage.To.Add(new MailAddress(model.Email));
            MailMessage.From       = new MailAddress("*****@*****.**");
            MailMessage.Subject    = "Your email subject";
            MailMessage.Body       = string.Format(body, model.Name, model.Email, model.Message, model.Subject, model.Phone);
            MailMessage.IsBodyHtml = true;



            SmtpClient client = new SmtpClient
            {
                Host                  = "webmail.technicalgroup.az",
                Port                  = 465,
                EnableSsl             = true,
                UseDefaultCredentials = false,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                Timeout               = 20000,
                Credentials           = new NetworkCredential
                {
                    UserName = "******",
                    Password = "******"
                }
            };

            client.Send(MailMessage);


            return(Json("Mesajınız uğurla göndərildi , təşəkkürlər !"));
        }
Exemplo n.º 4
0
        // GET: Home/Edit/5
        public ActionResult Edit(int id)
        {
            VMContact Contacts = null;

            try
            {
                Contacts = _contactServices.GetContactById(id);
            }
            catch (Exception)
            {
            }

            return(PartialView(Contacts));
        }
Exemplo n.º 5
0
        public int CreateContact(VMContact ContactEntity)
        {
            int result = 0;

            try
            {
                string strUri = string.Format("{0}{1}", url, "Contact");
                HttpResponseMessage responseMessage = client.PostAsync(strUri, new StringContent(
                                                                           new JavaScriptSerializer().Serialize(ContactEntity), Encoding.UTF8, "application/json")).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    result = 1;
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
Exemplo n.º 6
0
 public ActionResult Edit(VMContact model, int id)
 {
     if (ModelState.IsValid)
     {
         int result = _contactServices.UpdateContact(model);
         if (result > 0)
         {
             return(Json(new { Status = "0", Message = "Data inserted  sucessfully." }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { Status = "1", Message = "Error Occur during processing." }, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         ModelState.AddModelError("", "");
         return(Json(new { Status = "101", Message = "Enter Valid data" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 7
0
        public VMContact GetContactById(int ContactID)
        {
            VMContact contact = new VMContact();

            try
            {
                string strUri = string.Format("{0}{1}/{2}", url, "Contact", ContactID);
                HttpResponseMessage responseMessage = client.GetAsync(strUri).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    var responseData = responseMessage.Content.ReadAsStringAsync().Result;

                    contact = JsonConvert.DeserializeObject <VMContact>(responseData);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(contact);
        }