public ActionResult AddressCreate()
 {
     var listSelectListItems = new List<SelectListItem>();
     var products = _repository.Fetch<ProductType>().Where(p => p.Status == MyEnums.StatusOptions.Approved);
     foreach (var n in products)
     {
         var selectList = new SelectListItem()
         {
             Text = n.Description,
             Value = n.Id.ToString()
         };
         listSelectListItems.Add(selectList);
     }
     var Addresses = new RegisterViewModel();
     Addresses.Product = listSelectListItems;
     return View(Addresses);
 }
        public ActionResult AddressCreate(RegisterViewModel model )
        {
            var customeraddress = new MessagingContacts();
            var product = _repository.Find<ProductType>(Guid.Parse(model.ProductVal));
            try
            {
                if (ModelState.IsValid)
                {

                    customeraddress.Id = Guid.NewGuid();
                    customeraddress.Maker = User.Identity.GetUserName();
                    customeraddress.Osysdate = System.DateTime.Now;
                    customeraddress.MessagingCustomersId = Guid.Parse(Session["Id"].ToString());
                    customeraddress.Name = model.Name;
                    customeraddress.EmailAddress1 = model.EmailAddress1;
                        customeraddress.Phonenumber = model.Phonenumber;
                    customeraddress.Status = MyEnums.StatusOptions.Added;
                    customeraddress.ProductId = product.Id;
                    customeraddress.ProductType = product.Description;
                    _repository.SaveNew(customeraddress);
                    getVals.LogAudit(User.Identity.GetUserName(), "Created", Request.UserHostName, "Created Contact :" + customeraddress.Name, "Created", "Messaging");
                }

                return RedirectToAction("AddressIndex", new { id = customeraddress.MessagingCustomersId });
            }
            catch (Exception ex)
            {
                _logs.LogError(User.Identity.GetUserName(), "AddressesCreate", "Error: " + ex.Message,
                Request.ServerVariables["REMOTE_ADDR"], HttpContext.Server.MapPath("."), "Messaging");

                System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/errorLOG.txt"), System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
                System.IO.StreamWriter s = new System.IO.StreamWriter(fs);
                s.BaseStream.Seek(0, System.IO.SeekOrigin.End);
                s.WriteLine("ERROR DATE: " + System.DateTime.Now.ToString(System.Globalization.CultureInfo.InvariantCulture) + " \nERROR MESSAGE: " + ex.Message + "\nSOURCE: " + ex.Source + "\nFORM NAME: " + System.Web.HttpContext.Current.Request.Url.ToString() + "\nQUERYSTRING: " + Request.QueryString.ToString() + "\nTARGETSITE: " + ex.TargetSite.ToString() + "\nSTACKTRACE: " + ex.StackTrace + System.Diagnostics.EventLogEntryType.Error);
                s.WriteLine("-------------------------------------------------------------------------------------------------------------");
                s.Close();

                return View();
            }
        }