public async Task <ActionResult> Create([Bind(Include = "Id,FirstName,LastName,DateOfBirth,Address1,Address2,Suburb,City,HomePhone,MobilePhone,Email,JobTitle,PhotoLocation,UserType,IsActive,UserPassword")] user user)
        {
            var usert = db.users.Where(x => x.Email == user.Email).FirstOrDefault();

            if (usert == null)
            {
                if (ModelState.IsValid)
                {
                    user.IsActive = true;
                    if (user.UserType == null)
                    {
                        user.UserType = 2;  //2- normal user  1- admin user
                    }
                    db.users.Add(user);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                return(View("Create", user));
            }
            return(View(user));
        }
        public ActionResult ContactMail(ContactUsModel model)
        {
            ViewBag.reCAPTCHAClient = System.Configuration.ConfigurationManager.AppSettings["reCAPTCHAClient"];

            _logger.Info("contact us : " + model.CustomerName + " ::  " + model.Subject + " ::  " + model.Email + " ::  " + model.Message);
            ViewBag.Message = model.Message;
            ViewBag.Subject = model.Subject;

            string EncodedResponse = Request.Form["g-Recaptcha-Response"];
            bool   IsCaptchaValid  = (ReCaptchaClass.Validate(EncodedResponse) == "True" ? true : false);

            if (IsCaptchaValid)
            {
                infringementEntities db        = new infringementEntities();
                contactu             contactus = new contactu();

                contactus.SubjectText  = model.Subject;
                contactus.CustomerName = model.CustomerName;
                contactus.Email        = model.Email;
                contactus.SubjectText  = model.Subject;
                contactus.BodyContent  = model.Message;
                contactus.CreatedDate  = DateTime.Now;

                string VisitorsIPAddr = string.Empty;
                if (HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
                {
                    VisitorsIPAddr = HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                }
                else if (HttpContext.Request.UserHostAddress.Length != 0)
                {
                    VisitorsIPAddr = HttpContext.Request.UserHostAddress;
                }
                contactus.ClientIp    = VisitorsIPAddr;
                contactus.BrowserName = Request.Browser.Browser;
                contactus.Status      = 0;

                db.contactus.Add(contactus);
                db.SaveChangesAsync();

                //sending mail
                StringBuilder sb = new StringBuilder();
                sb.Append("<p>The following has been sent from contact us page.</p>");
                sb.Append("<p>Submit Date & Time: " + GetCurrentTime().ToString("dd-MM-yyyy HH:mm") + " </p>");

                sb.Append("<p>Name : " + model.CustomerName + " ");
                sb.Append("<p>Email : " + model.Email + " ");
                sb.Append("<p>Message Type : " + model.Subject + " </p>");
                sb.Append("<p> Infringement Number :" + model.InfringementNumber + " </p>");
                sb.Append("<p> Message :" + model.Message + " </p>");
                //sb.Append("<p>&nbsp;</p>");
                //sb.Append("<p>Thanks</p>");
                //sb.Append("<p>Online Contact us web form -Customer Portal.</p>");

                string emailid = db.emailids.FirstOrDefault(x => x.EmailTitle == "contactus").Email;

                SendMail(emailid, model.Subject, sb.ToString());

                return(View("MailResponse"));
            }
            else
            {
                ModelState.AddModelError("", "Please select valid recaptcha.");
                return(View("Contact", model));
            }
        }