This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct DateTimeOffsetWrapper | |
{ | |
private static DateTimeOffset? _dateTimeOffset; | |
public static DateTimeOffset Now => _dateTimeOffset ?? DateTimeOffset.Now; | |
/// <summary> | |
/// This method can be used to initialize our internal DateTimeOffset object to the desired date and time | |
/// </summary> | |
/// <param name="dateTimeOffset">Desired date and time</param> | |
public static void SetDateTimeOffset(DateTimeOffset dateTimeOffset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public decimal CalculateDiscount(decimal totalAmount) | |
{ | |
decimal discountPercentage; | |
if (DateTimeOffset.Now.Hour >= 22 || DateTimeOffset.Now.Hour < 6) | |
discountPercentage = 25; | |
else | |
discountPercentage = 10; | |
return totalAmount - ((totalAmount * discountPercentage) / 100); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using JWT; | |
namespace MyJWTUtility | |
{ | |
public static class JWTUtility | |
{ | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formData = new FormData(); | |
var photoFileName = "MyPhoto.jpg"; | |
var signFileName = "MySign.jpg"; | |
var thumbFileName = "MyThumb.jpg"; | |
formData.append("Photo", "<<image in base64 format>>"); | |
formData.append("Sign", "<<image in base64 format>>"); | |
formData.append("Thumb", "<<image in base64 format>>"); | |
formData.append("Token", "<<append the JWT in this parameter>>"); | |
formData.append("PhotoUploaded", "Y");//N if not uploading a photo | |
formData.append("SignUploaded", "Y"); //N if not uploading a sign |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formData = new FormData(); | |
var photoFileName = "MyPhoto.jpg"; | |
var signFileName = "MySign.jpg"; | |
formData.append("Photo", "<<image in base64 format>>"); | |
formData.append("Sign", "<<image in base64 format>>"); | |
formData.append("Token", "<<append the JWT in this parameter>>"); | |
formData.append("PhotoUploaded", "Y");//N if not uploading a photo | |
formData.append("SignUploaded", "Y"); //N if not uploading a sign | |
formData.append("PhotoFileName", photoFileName); | |
formData.append("SignFileName", signFileName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formData = new FormData(); | |
formData.append("Photo", $("#filePhotoUpload").get(0).files[0]);//filePhotoUpload is html file element | |
formData.append("Sign", $("#fileSignUpload").get(0).files[0]);//fileSignUpload is html file element | |
formData.append("Token", "<<append the JWT in this parameter>>"); | |
formData.append("PhotoUploaded", "Y"); //N if not uploading a photo | |
formData.append("SignUploaded", "Y"); //N if not uploading a sign | |
var ajaxRequest = $.ajax({ | |
type: "POST", | |
url: 'fileserver.com/FileUploader/api/filenx/UploadPhotoSign', | |
data: formData, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = new FormData(); | |
data.append("UploadedImage", $("#fileUpload").get(0).files[0]); | |
data.append("Token", "<<append the JWT in this parameter>>"); | |
var ajaxRequest = $.ajax({ | |
type: "POST", | |
url: 'fileserver.com/FileUploader/api/filenx/Upload', | |
contentType: false, | |
processData: false, | |
data: data | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('authInterceptor', ['$q', function ($q) { | |
return { | |
request: function (config) { | |
config.headers = config.headers || {}; | |
if (config.headers.skipAuthorization === false) { | |
var token = localStorage.getItem('authenticationToken'); | |
if (token != null) { | |
config.headers.Authorization = token; | |
} | |
} |