public async Task <LeadResponse> AddNewLead(AddNewLeadCommand request) { var newJob = JobsMapper.ToJobs(request); _context.Jobs.Add(newJob); await _context.SaveChangesAsync(); return(JobsMapper.ToLeadResponse(newJob)); }
public void Should_Return_Jobs_object_Given_AddNewLeadCommand_object() { var leadCmd = new AddNewLeadCommand(1, 1, "_ContactName", "0123456789", "*****@*****.**", 100, "_Description"); var job = JobsMapper.ToJobs(leadCmd); Assert.NotNull(job); Assert.AreEqual(job.Status, LeadStatusType.New.ToString()); Assert.AreEqual(job.ContactName, leadCmd.ContactName); Assert.AreEqual(job.SuburbId, leadCmd.SuburbId); Assert.AreEqual(job.CategoryId, leadCmd.CategoryId); Assert.AreEqual(job.Description, leadCmd.Description); Assert.AreEqual(job.Price, leadCmd.Price); Assert.AreEqual(job.ContactEmail, leadCmd.ContactEmail); Assert.AreEqual(job.ContactPhone, leadCmd.ContactPhone); }
public static Jobs ToJobs(AddNewLeadCommand request) { var result = new Jobs() { Status = LeadStatusType.New.ToString(), ContactName = request.ContactName, SuburbId = request.SuburbId, CategoryId = request.CategoryId, Description = request.Description, Price = request.Price, ContactEmail = request.ContactEmail, ContactPhone = request.ContactPhone, CreatedAt = DateTime.Now }; return(result); }
public async Task <IActionResult> AddNewLead([FromBody] AddNewLeadCommand command) { var result = await _mediator.Send(command); return(CreatedAtAction(nameof(GetLead), new { id = result.Id }, result)); }