public void DeliveryReportItemShouldHaveCorrectProperties() { Type type = typeof(DeliveryReportItem); type.GetProperties().Length.Should().Be(14); DeliveryReportItem classUnderTest = new DeliveryReportItem { Id = 1, AnnexId = 10, NumberOfPackages = 10, FullName = "Test", TelephoneNumber = "Test", MobileNumber = "Test", FullAddress = "Test", Postcode = "E5", Uprn = "100435", AnyFoodHouseholdCannotEat = "test", DeliveryNotes = "Test", }; Assert.That(classUnderTest, Has.Property("Id").InstanceOf(typeof(Int32))); Assert.That(classUnderTest, Has.Property("AnnexId").InstanceOf(typeof(Int32))); Assert.That(classUnderTest, Has.Property("NumberOfPackages").InstanceOf(typeof(Int32))); Assert.That(classUnderTest, Has.Property("FullName").InstanceOf(typeof(string))); Assert.That(classUnderTest, Has.Property("TelephoneNumber").InstanceOf(typeof(string))); Assert.That(classUnderTest, Has.Property("MobileNumber").InstanceOf(typeof(string))); Assert.That(classUnderTest, Has.Property("FullAddress").InstanceOf(typeof(string))); Assert.That(classUnderTest, Has.Property("Postcode").InstanceOf(typeof(string))); Assert.That(classUnderTest, Has.Property("Uprn").InstanceOf(typeof(string))); Assert.That(classUnderTest, Has.Property("AnyFoodHouseholdCannotEat").InstanceOf(typeof(string))); Assert.That(classUnderTest, Has.Property("DeliveryNotes").InstanceOf(typeof(string))); }
public static DeliveryReportItemResponse ToResponse(this DeliveryReportItem item) { return(new DeliveryReportItemResponse() { Id = item.Id, AnnexId = item.AnnexId, NumberOfPackages = item.NumberOfPackages, FullName = item.FullName, TelephoneNumber = item.TelephoneNumber, MobileNumber = item.MobileNumber, FullAddress = item.FullAddress, Postcode = item.Postcode, Uprn = item.Uprn, AnyFoodHouseholdCannotEat = item.AnyFoodHouseholdCannotEat, DeliveryNotes = item.DeliveryNotes, DeliveryDate = item.DeliveryDate, LastConfirmedDeliveryDate = item.LastConfirmedDeliveryDate, BatchId = item.BatchId }); }
public List <DeliveryReportItem> CreateDeliverySchedule(int limit, string spreadsheet, DateTime deliveryDate) { var deliveryData = new List <DeliveryReportItem>(); var data = GetData(limit, deliveryDate); var batch = new DeliveryBatch { DeliveryDate = deliveryDate, DeliveryPackages = data.Count, ReportFileId = spreadsheet }; _dbContext.DeliveryBatch.Add(batch); _dbContext.SaveChanges(); foreach (var record in data) { var saveRecord = new DeliveryReportItem() { AnnexId = record.Id, NumberOfPackages = 1, AnyFoodHouseholdCannotEat = record.AnyFoodHouseholdCannotEat, BatchId = batch.Id, FullName = $"{record.FirstName} {record.LastName}", FullAddress = $"{record.AddressFirstLine} {record.AddressSecondLine} {record.AddressThirdLine}", Postcode = record.Postcode, Uprn = record.Uprn, TelephoneNumber = record.ContactTelephoneNumber, MobileNumber = record.ContactMobileNumber, DeliveryDate = deliveryDate, LastConfirmedDeliveryDate = record.LastConfirmedFoodDelivery, DeliveryNotes = record.DeliveryNotes }; _dbContext.DeliveryReportData.Add(saveRecord); deliveryData.Add(saveRecord); } _dbContext.SaveChanges(); return(deliveryData); }