public ActionResult Create(Agent agent) { if (ModelState.IsValid) { return RedirectToAction("Index"); } return View(agent); }
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; } }
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; } }
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; }
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; }
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"); }