Skip to content

Commit

Permalink
Merge pull request #310 from qccoders/develop
Browse files Browse the repository at this point in the history
Prod deploy 1.1
  • Loading branch information
jpdillingham authored Dec 13, 2018
2 parents c8debe6 + eda3750 commit 8399769
Show file tree
Hide file tree
Showing 140 changed files with 10,757 additions and 9,409 deletions.
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,15 @@ matrix:
secure: Xd6dEKIV6PS8dpZnG234m0R/9OE0Niqz/1kxGDvH2k4sRY0l3yF4WGf3DPvxI5I0jRuJuA/bFgAcGkhvhUG2wmTUawM58TO4jnDkQlSlj5pXuGRiyJiSVxnanRSp63dbfNDM7KCw8M1Tw5XQXKZVUynzbne/EeYs/c+jyAIX8OMMyHMPm1wE5m/cYiAl97AePlLtJhFB0hxG4GbmzNqiBHSuppPViY63wnfv0sfs0leXnPZ9UNEahfbuuFWymZxvJTmpdD5/4UrAw68C7GH8IQ5Z+2oWIlooTteNiDyNiFzX4aCKZ6SfQJAH+HInpPDfR2LKi0xKChb2RLccvW3FnCENyEihNYmELE0uiGHrELBIBZXWFH/8qH+2+4nOWuhEGhmdywTOpIYdOrXTpwxsMCc+42eD12NNeGFRSoOu+nqsDl3ifI3C0ZYrKYb70i78IlAcnki68UwWhvJhSA9TymwXV4INhiiTE3TQhw9duwlwMnxk+PTIhBt2tEjggDIcjCc75r6GTYdhex/r/PEYBL24qVM82GHeOKz0u4Ew85XpU/W9BwKu7tFzI8pxow8F0UCoKkcqDfNioqFx91qmrimFh5Z0GAsh4honixBWqEzBhKRVBNkHVrJ23PxPQBoX8n7EI7ehXGPnb2rVvcSkoQkHsl8NmYZkjYviv2y9ezc=
on:
repo: qccoders/QCVOC
branch: master
branch: master
- language: android
stage: Android
android:
components:
- build-tools-28.0.2
- android-26
- extra-google-google_play_services
before_script:
- cd mobile
script:
- ./gradlew --quiet build
18 changes: 9 additions & 9 deletions api/QCVOC.Api/Scans/Controller/ScansController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public IActionResult Scan([FromBody]ScanRequest scan)
}

var veteran = VeteranRepository
.GetAll(new VeteranFilters() { CardNumber = scan.CardNumber })
.GetAll(new VeteranFilters() { CardNumber = scan.CardNumber, IncludePhotoBase64 = true })
.SingleOrDefault();

if (veteran == default(Veteran))
Expand All @@ -128,15 +128,15 @@ public IActionResult Scan([FromBody]ScanRequest scan)

if (existingCheckIn == default(Scan))
{
return CreateScan(scanRecord);
return CreateScan(scanRecord, veteran);
}
else if (existingCheckIn.PlusOne != scan.PlusOne)
{
return UpdateScan(scanRecord);
return UpdateScan(scanRecord, veteran);
}
else
{
return StatusCode(200, existingCheckIn);
return StatusCode(200, new ScanResponse(existingCheckIn, veteran));
}
}

Expand All @@ -157,28 +157,28 @@ public IActionResult Scan([FromBody]ScanRequest scan)
return StatusCode(200, previousScans.Where(s => s.ServiceId == scan.ServiceId).SingleOrDefault());
}

return CreateScan(scanRecord);
return CreateScan(scanRecord, veteran);
}

private IActionResult CreateScan(Scan scan)
private IActionResult CreateScan(Scan scan, Veteran veteran)
{
try
{
var createdScan = ScanRepository.Create(scan);
return StatusCode(201, createdScan);
return StatusCode(201, new ScanResponse(createdScan, veteran));
}
catch (Exception ex)
{
throw new Exception($"Error processing Scan: {ex.Message}. See inner Exception for details.", ex);
}
}

private IActionResult UpdateScan(Scan scan)
private IActionResult UpdateScan(Scan scan, Veteran veteran)
{
try
{
var updatedScan = ScanRepository.Update(scan);
return StatusCode(201, updatedScan);
return StatusCode(201, new ScanResponse(updatedScan, veteran));
}
catch (Exception ex)
{
Expand Down
77 changes: 77 additions & 0 deletions api/QCVOC.Api/Scans/Data/DTO/ScanResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// <copyright file="ScanResponse.cs" company="QC Coders">
// Copyright (c) QC Coders. All rights reserved. Licensed under the GPLv3 license. See LICENSE file
// in the project root for full license information.
// </copyright>

namespace QCVOC.Api.Scans.Data.DTO
{
using System;
using QCVOC.Api.Scans.Data.Model;
using QCVOC.Api.Veterans.Data.Model;

/// <summary>
/// DTO containing the result of a Scan.
/// </summary>
public class ScanResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="ScanResponse"/> class with the specified <paramref name="scan"/> and <paramref name="veteran"/>.
/// </summary>
/// <param name="scan">The Scan to include in the response.</param>
/// <param name="veteran">The Veteran associated with the scan, if applicable.</param>
public ScanResponse(Scan scan, Veteran veteran)
{
EventId = scan.EventId;
VeteranId = scan.VeteranId;
Veteran = veteran;
ServiceId = scan.ServiceId;
PlusOne = scan.PlusOne;
ScanBy = scan.ScanBy;
ScanById = scan.ScanById;
ScanDate = scan.ScanDate;
}

/// <summary>
/// Gets or sets the id of the Event.
/// </summary>
public Guid EventId { get; set; }

/// <summary>
/// Gets or sets the id of the Veteran.
/// </summary>
public Guid VeteranId { get; set; }

/// <summary>
/// Gets or sets the Veteran associated with the Scan.
/// </summary>
public Veteran Veteran { get; set; }

/// <summary>
/// Gets or sets the id of the Service.
/// </summary>
/// <remarks>
/// If null, represents a check-in Scan.
/// </remarks>
public Guid ServiceId { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the Veteran brought a guest.
/// </summary>
public bool PlusOne { get; set; }

/// <summary>
/// Gets or sets the name of the user who performed the Scan.
/// </summary>
public string ScanBy { get; set; }

/// <summary>
/// Gets or sets the id of the user who performed the Scan.
/// </summary>
public Guid ScanById { get; set; }

/// <summary>
/// Gets or sets the date on which the Scan was performed.
/// </summary>
public DateTime ScanDate { get; set; }
}
}
5 changes: 0 additions & 5 deletions api/QCVOC.Api/Scans/Data/Model/Scan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ public class Scan : IEquatable<Scan>
/// </summary>
public Guid VeteranId { get; set; }

/// <summary>
/// Gets or sets the full name of the Veteran.
/// </summary>
public string Veteran { get; set; }

/// <summary>
/// Gets or sets the id of the Service.
/// </summary>
Expand Down
6 changes: 2 additions & 4 deletions api/QCVOC.Api/Scans/Data/Repository/ScanRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ public IEnumerable<Scan> GetAll(Filters filters = null)
s.plusone,
s.scandate,
s.scanbyid,
a.name AS scanby,
v.firstname || ' ' || v.lastname AS veteran
a.name AS scanby
FROM scans s
LEFT JOIN accounts a ON s.scanbyid = a.id
INNER JOIN veterans v ON s.veteranid = v.id
Expand All @@ -162,8 +161,7 @@ LIMIT @limit OFFSET @offset
.ApplyFilter(FilterType.Equals, "s.eventid", scanFilters.EventId)
.ApplyFilter(FilterType.Equals, "s.veteranid", scanFilters.VeteranId)
.ApplyFilter(FilterType.Equals, "s.serviceid", scanFilters.ServiceId)
.ApplyFilter(FilterType.Equals, "s.plusone", scanFilters.PlusOne)
.ApplyFilter(FilterType.Equals, "v.firstname || ' ' || v.lastname", scanFilters.Veteran);
.ApplyFilter(FilterType.Equals, "s.plusone", scanFilters.PlusOne);
}

using (var db = ConnectionFactory.CreateConnection())
Expand Down
5 changes: 0 additions & 5 deletions api/QCVOC.Api/Scans/ScanFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public class ScanFilters : Filters
/// </summary>
public Guid? VeteranId { get; set; }

/// <summary>
/// The full name of the Veteran.
/// </summary>
public string Veteran { get; set; }

/// <summary>
/// The id of the Service.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion api/QCVOC.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,4 @@ private static string GetXmlCommentsFilePath()
return Path.Combine(basePath, fileName);
}
}
}
}
5 changes: 3 additions & 2 deletions api/QCVOC.Api/Veterans/Controller/VeteransController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace QCVOC.Api.Veterans.Controller
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using QCVOC.Api.Common;
using QCVOC.Api.Common.Data.Repository;
using QCVOC.Api.Security;
Expand Down Expand Up @@ -144,6 +143,7 @@ public IActionResult Enroll([FromBody]VeteranEnrollRequest veteran)
LastUpdateDate = DateTime.UtcNow,
LastUpdateById = User.GetId(),
CardNumber = veteran.CardNumber,
PhotoBase64 = veteran.PhotoBase64,
PrimaryPhone = veteran.PrimaryPhone,
VerificationMethod = veteran.VerificationMethod,
};
Expand Down Expand Up @@ -228,6 +228,7 @@ public IActionResult Update([FromRoute]Guid id, [FromBody]VeteranUpdateRequest v
LastUpdateDate = DateTime.UtcNow,
LastUpdateById = User.GetId(),
CardNumber = veteran.CardNumber,
PhotoBase64 = veteran.PhotoBase64,
PrimaryPhone = veteran.PrimaryPhone,
VerificationMethod = veteran.VerificationMethod,
};
Expand Down Expand Up @@ -280,4 +281,4 @@ public IActionResult Delete([FromRoute]Guid id)
}
}
}
}
}
7 changes: 6 additions & 1 deletion api/QCVOC.Api/Veterans/Data/DTO/VeteranEnrollRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ public class VeteranEnrollRequest
/// </summary>
[Required]
public VerificationMethod VerificationMethod { get; set; }

/// <summary>
/// Gets or sets the photo of the veteran.
/// </summary>
public string PhotoBase64 { get; set; }
}
}
}
7 changes: 6 additions & 1 deletion api/QCVOC.Api/Veterans/Data/DTO/VeteranUpdateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ public class VeteranUpdateRequest
/// </summary>
[Required]
public VerificationMethod VerificationMethod { get; set; }

/// <summary>
/// Gets or sets the photo of the veteran.
/// </summary>
public string PhotoBase64 { get; set; }
}
}
}
8 changes: 7 additions & 1 deletion api/QCVOC.Api/Veterans/Data/Model/Veteran.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class Veteran : IEquatable<Veteran>
/// </summary>
public DateTime EnrollmentDate { get; set; }

/// <summary>
/// Gets or sets the photo of the veteran.
/// </summary>
public string PhotoBase64 { get; set; }

/// <summary>
/// Gets or sets the first name of the Veteran.
/// </summary>
Expand Down Expand Up @@ -107,6 +112,7 @@ public bool Equals(Veteran veteran)
&& this.LastUpdateById == veteran.LastUpdateById
&& this.LastUpdateBy == veteran.LastUpdateBy
&& this.Address == veteran.Address
&& this.PhotoBase64 == veteran.PhotoBase64
&& this.PrimaryPhone == veteran.PrimaryPhone
&& this.Email == veteran.Email
&& this.EnrollmentById == veteran.EnrollmentById
Expand All @@ -115,4 +121,4 @@ public bool Equals(Veteran veteran)
&& this.EnrollmentDate - veteran.EnrollmentDate <= TimeSpan.FromSeconds(1);
}
}
}
}
14 changes: 10 additions & 4 deletions api/QCVOC.Api/Veterans/Data/Repository/VeteranRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ INSERT INTO veterans (
lastupdatedate,
lastupdatebyid,
address,
photobase64,
primaryphone,
email,
enrollmentdate,
Expand All @@ -63,6 +64,7 @@ INSERT INTO veterans (
@lastupdatedate,
@lastupdatebyid,
@address,
@photobase64,
@primaryphone,
@email,
@enrollmentdate,
Expand All @@ -81,6 +83,7 @@ INSERT INTO veterans (
lastupdatedate = veteran.LastUpdateDate,
lastupdatebyid = veteran.LastUpdateById,
address = veteran.Address,
photobase64 = veteran.PhotoBase64,
primaryphone = veteran.PrimaryPhone,
email = veteran.Email,
enrollmentdate = veteran.EnrollmentDate,
Expand All @@ -107,7 +110,7 @@ public void Delete(Guid id)

var query = builder.AddTemplate(@"
UPDATE veterans
SET
SET
deleted = true,
cardnumber = NULL
WHERE id = @id
Expand Down Expand Up @@ -137,7 +140,7 @@ public void Delete(Veteran veteran)
/// <returns>The Veteran matching the specified id.</returns>
public Veteran Get(Guid id)
{
return GetAll(new VeteranFilters() { Id = id }).SingleOrDefault();
return GetAll(new VeteranFilters() { Id = id, IncludePhotoBase64 = true }).SingleOrDefault();
}

/// <summary>
Expand All @@ -160,14 +163,15 @@ public IEnumerable<Veteran> GetAll(Filters filters = null)
a.name AS lastupdateby,
v.lastupdatebyid,
v.address,
{(((VeteranFilters)filters).IncludePhotoBase64 ? "v.photobase64," : string.Empty)}
v.primaryphone,
v.email,
v.enrollmentdate,
v.enrollmentbyid,
b.name AS enrollmentby,
v.verificationmethod
FROM veterans v
LEFT JOIN accounts a ON v.lastupdatebyid = a.id
LEFT JOIN accounts a ON v.lastupdatebyid = a.id
LEFT JOIN accounts b ON v.enrollmentbyid = b.id
/**where**/
ORDER BY (firstname || lastname) {filters.OrderBy.ToString()}
Expand Down Expand Up @@ -220,6 +224,7 @@ UPDATE veterans
lastupdatedate = @lastupdatedate,
lastupdatebyid = @lastupdatebyid,
address = @address,
photobase64 = @photobase64,
primaryphone = @primaryphone,
email = @email,
verificationmethod = @verificationmethod
Expand All @@ -234,6 +239,7 @@ UPDATE veterans
lastupdatedate = veteran.LastUpdateDate,
lastupdatebyid = veteran.LastUpdateById,
address = veteran.Address,
photobase64 = veteran.PhotoBase64,
primaryPhone = veteran.PrimaryPhone,
email = veteran.Email,
id = veteran.Id,
Expand All @@ -248,4 +254,4 @@ UPDATE veterans
return Get(veteran.Id);
}
}
}
}
5 changes: 5 additions & 0 deletions api/QCVOC.Api/Veterans/VeteranFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class VeteranFilters : Filters
/// </summary>
public Guid? Id { get; set; }

/// <summary>
/// A value indicating whether the PhotoBase64 data should be included in the results.
/// </summary>
public bool IncludePhotoBase64 { get; set; }

/// <summary>
/// The last name of the Veteran.
/// </summary>
Expand Down
8 changes: 0 additions & 8 deletions mobile-new/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion mobile-new/app/.gitignore

This file was deleted.

Loading

0 comments on commit 8399769

Please sign in to comment.