Exemple #1
0
        public ActionResult Create(Agent agent)
        {
            if (ModelState.IsValid)
            {
                return RedirectToAction("Index");
            }

            return View(agent);
        }
Exemple #2
0
 public static bool SendAgentInvite(Agent agent)
 {
     try
     {
     SingleUseEntity suc = GenerateUniqueCode(agent.Email, "Agent");
     var body = PopulateBodyInviteAgent(agent.Email, "Agent", suc.SUC.ToString());
     var message = new MailMessage(agent.Email, "*****@*****.**", "test invite for pos", body);
     var client = new SmtpClient();
     client.EnableSsl = true;
     client.Send(message);
     return true;
     }
     catch(Exception ex)
     {
         return false;
     }
 }
Exemple #3
0
        public static bool CreateAgent(Agent agent)
        {
            try
            {

                using (var ctx = new PosContext())
                {
                    var found = ctx.Agent.FirstOrDefault(a => a.UserId == agent.UserId);
                    if (found == null)
                    {
                        ctx.Agent.Add(agent);
                        ctx.SaveChanges();
                        return true;
                    }
                    return false;

                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }
Exemple #4
0
        public bool CreateAgent(FormCollection data, string userid)
        {
            int AgencyId = Convert.ToInt32(data["AgencyId"]);
            string Forename = Convert.ToString(data["ForeName"]);
            string Email = Convert.ToString(data["Email"]);
            string PostCode = Convert.ToString(data["PostCode"]);
            string Address = Convert.ToString(data["Address"]);
            string Country = Convert.ToString(data["Country"]);
            string City = Convert.ToString(data["City"]);
            DateTime Dob = Convert.ToDateTime(data["Dob"]);
            string PhoneNumber = Convert.ToString(data["PhoneNumber"]);
            string Lastname = Convert.ToString(data["Lastname"]);

            var agent = new Agent
            {
                UserId = userid,
                Email = Email,
                Forename = Forename,
                PostCode = PostCode,
                AddressLine = Address,
                Country = Country,
                City = City,
                Dob = Dob,
                PhoneNumber = PhoneNumber,
                Lastname = Lastname,
                AgencyId = AgencyId
            };
            if (AgentContext.CreateAgent(agent)) return true;

            return false;

        }
Exemple #5
0
        private bool CreateAgent(RegisterViewModelAgent data, string userid)
        {
            var agent = new Agent
            {
                UserId = userid,
                Email = data.Agent.Email,
               Forename  = data.Agent.Forename,
                Lastname = data.Agent.Lastname,
                PostCode = data.Agent.PostCode,
                AddressLine = data.Agent.AddressLine,
                Country = data.Agent.Country,
                City = data.Agent.City,
                PhoneNumber = data.Agent.PhoneNumber,
                Dob = data.Agent.Dob,
                AgencyId = data.Agent.AgencyId
            }; 
            if (AgentContext.CreateAgent(agent)) return true;

            return false;
        }
Exemple #6
0
 public ActionResult InviteAgent(Agent data)
 {
     if (ModelState.IsValid)
     {
         var sent = EmailHelper.SendAgentInvite(data);
         if (sent)
         {
             ViewBag.Message = "Invite Sent to " + data.Email;
             return RedirectToAction("Index");
         }
     }
     ViewBag.Message = "Failed to send invite " + data.Email;
     return RedirectToAction("Index");
 }