public async Task <LeadResponse> AddNewLead(AddNewLeadCommand request) { var newJob = JobsMapper.ToJobs(request); _context.Jobs.Add(newJob); await _context.SaveChangesAsync(); return(JobsMapper.ToLeadResponse(newJob)); }
public async Task <LeadResponse> GetLeadById(int id) { var jobs = await _context.Jobs.Where(s => s.Id == id) .Include(x => x.Suburb) .Include(x => x.Category) .FirstOrDefaultAsync(); if (jobs == null) { return(null); } return(JobsMapper.ToLeadResponse(jobs)); }
public async Task Should_Return_LeadResponse_object_Given_Jobs_object() { var dbContext = await InMemoryMockDbContext.GetDatabaseContext(); var jobs = dbContext.Jobs.ToList().First(); var leadResp = JobsMapper.ToLeadResponse(jobs); Assert.NotNull(leadResp); Assert.AreEqual(leadResp.Id, jobs.Id); Assert.AreEqual(leadResp.ContactName, jobs.ContactName); Assert.AreEqual(leadResp.CreatedDateTime, jobs.CreatedAt.DateTime); Assert.AreEqual(leadResp.Suburb, jobs.Suburb.Name); Assert.AreEqual(leadResp.CategoryName, jobs.Category.Name); Assert.AreEqual(leadResp.Description, jobs.Description); Assert.AreEqual(leadResp.Price, jobs.Price.ToString()); Assert.AreEqual(leadResp.Postcode, jobs.Suburb.Postcode); Assert.AreEqual(leadResp.Status, jobs.Status); }