Example #1
0
        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()))
                                 ));
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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);
            }
        }
Example #4
0
        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));
        }