public IActionResult AddAgentByAgencyUUID(Guid agencyUUID, [FromBody] AgentCreate model) { var result = _agentService.Add(agencyUUID, model.ToDataModel()); return(ProcessResult(result, a => Ok(new BaseResponse <Agent>(a.ToDTOModel())) )); }
public bool CreateAgent(AgentCreate model) { var entity = new Agent() { OwnerId = _userId, Title = model.Title, Content = model.Content, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Agent.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateAgent(AgentCreate model) { var entity = new Agent() { LicenseNumber = model.LicenseNumber, Name = model.Name, Email = model.Email, Address = model.Address, PhoneNumber = model.PhoneNumber }; using (var ctx = new ApplicationDbContext()) { ctx.Agents.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(AgentCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new AgentService(); if (service.CreateAgent(model)) { TempData["SaveResult"] = "The agent was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "The agent could not be created."); return(View(model)); }