Commit 8bf3ca87 authored by Sandeep Sagar Panjala's avatar Sandeep Sagar Panjala

initial commit

parent 73cf0682
namespace Hims.Api.Extensions
{
using System.Text.Json;
using System.Text.Json.Serialization;
using AutoMapper;
using Filters;
using Infrastructure.Helpers.Middleware;
using Infrastructure.Repositories.Middleware;
using Infrastructure.Services.Middleware;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.DependencyInjection;
using Profiles;
using Senders;
/// <summary>
/// The service collection extensions.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// The register services.
/// </summary>
/// <param name="services">
/// The services.
/// </param>
/// <returns>
/// The <see cref="IServiceCollection"/>.
/// </returns>
public static IServiceCollection RegisterServices(this IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy(
"CorsPolicy",
builder => builder.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials().SetIsOriginAllowed(origin => true));
});
services.AddOptions();
services.RegisterHelpers();
services.RegisterRepositories();
services.RegisterBusinessServices();
services.AddTransient<ISMSSender, SMSSender>();
services.AddTransient<IEmailSender, EmailSender>();
services.AddTransient<IWhatsAppSMSSender, WhatsAppSMSSender>();
var mappingConfig = new MapperConfiguration(mc =>
{
mc.AddProfile(new MappingProfile());
});
var mapper = mappingConfig.CreateMapper();
services.AddSingleton(mapper);
services.AddControllersWithViews(config =>
{
config.Filters.Add(typeof(ExceptionFilter));
config.RespectBrowserAcceptHeader = false;
config.ReturnHttpNotAcceptable = true;
})
.AddJsonOptions(a =>
{
a.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
a.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
services.Configure<FormOptions>(
x =>
{
x.ValueLengthLimit = int.MaxValue;
x.MultipartBodyLengthLimit = int.MaxValue;
});
services.AddAntiforgery(options => options.SuppressXFrameOptionsHeader = true);
services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");
services.AddSignalR();
return services;
}
}
}
\ No newline at end of file
namespace Hims.Api.Filters
{
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
/// <inheritdoc />
public class AppendAuthorizeToSummaryOperationFilter : IOperationFilter
{
/// <summary>
/// The filter.
/// </summary>
private readonly AppendAuthorizeToSummaryOperationFilter<AuthorizeAttribute> filter;
/// <summary>
/// Initializes a new instance of the <see cref="AppendAuthorizeToSummaryOperationFilter"/> class.
/// </summary>
public AppendAuthorizeToSummaryOperationFilter()
{
var policySelector = new PolicySelectorWithLabel<AuthorizeAttribute>
{
Label = "Policies",
Selector = authAttributes =>
authAttributes
.Where(a => !string.IsNullOrEmpty(a.Policy))
.Select(a => a.Policy)
};
var rolesSelector = new PolicySelectorWithLabel<AuthorizeAttribute>
{
Label = "Roles",
Selector = authAttributes =>
authAttributes
.Where(a => !string.IsNullOrEmpty(a.Roles))
.Select(a => a.Roles)
};
this.filter = new AppendAuthorizeToSummaryOperationFilter<AuthorizeAttribute>(new[] { policySelector, rolesSelector }.AsEnumerable());
}
/// <inheritdoc />
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
this.filter.Apply(operation, context);
}
}
}
namespace Hims.Api.Filters
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
/// <inheritdoc />
public class AppendAuthorizeToSummaryOperationFilter<T> : IOperationFilter where T : Attribute
{
/// <summary>
/// The policy selectors.
/// </summary>
private readonly IEnumerable<PolicySelectorWithLabel<T>> policySelectors;
/// <summary>
/// Initializes a new instance of the <see cref="AppendAuthorizeToSummaryOperationFilter{T}"/> class.
/// </summary>
/// <param name="policySelectors">
/// The policy selectors.
/// </param>
public AppendAuthorizeToSummaryOperationFilter(IEnumerable<PolicySelectorWithLabel<T>> policySelectors) => this.policySelectors = policySelectors;
/// <inheritdoc />
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
var authorizeAttributes = context.MethodInfo.DeclaringType?.GetCustomAttributes(true)
.Union(context.MethodInfo.GetCustomAttributes(true))
.OfType<T>()
.ToList();
if (authorizeAttributes != null && authorizeAttributes.Any() && this.policySelectors.Any())
{
var authorizationDescription = new StringBuilder(string.Empty);
foreach (var policySelector in this.policySelectors)
{
AppendPolicies(authorizeAttributes, authorizationDescription, policySelector);
}
operation.Summary += authorizationDescription.ToString().TrimEnd(';');
}
}
/// <summary>
/// The append policies.
/// </summary>
/// <param name="authorizeAttributes">
/// The authorize attributes.
/// </param>
/// <param name="authorizationDescription">
/// The authorization description.
/// </param>
/// <param name="policySelector">
/// The policy selector.
/// </param>
private static void AppendPolicies(IEnumerable<T> authorizeAttributes, StringBuilder authorizationDescription, PolicySelectorWithLabel<T> policySelector)
{
var policies = policySelector.Selector(authorizeAttributes).OrderBy(policy => policy).ToList();
if (policies.Any())
{
authorizationDescription.Append($" {policySelector.Label}: {string.Join(", ", policies)};");
}
}
}
}
namespace Hims.Api.Filters
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
/// <inheritdoc />
public class SecurityRequirementsOperationFilter : IOperationFilter
{
/// <inheritdoc />
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
var authAttributes = context.MethodInfo.DeclaringType?.GetCustomAttributes(true)
.Union(context.MethodInfo.GetCustomAttributes(true)).OfType<AuthorizeAttribute>();
if (authAttributes != null && authAttributes.Any())
{
operation.Responses.Add("401", new OpenApiResponse { Description = "Unauthorized" });
operation.Responses.Add("403", new OpenApiResponse { Description = "Forbidden" });
operation.Security = new List<OpenApiSecurityRequirement>
{
new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference { Id = "Bearer", Type = ReferenceType.SecurityScheme },
UnresolvedReference = true
},
new List<string>()
}
}
};
}
}
}
}
\ No newline at end of file
namespace Hims.Api.Filters
{
using System;
using System.Net;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Http;
using Hims.Domain.Services;
using Hims.Domain.Configurations;
using Hims.Api.Senders;
using Hims.Shared.EntityModels;
/// <inheritdoc />
/// <summary>
/// The exception filter.
/// </summary>
public class ExceptionFilter : IExceptionFilter
{
/// <summary>
/// The exception log services.
/// </summary>
private readonly IExceptionLogService exceptionLogServices;
/// <summary>
/// The email sender.
/// </summary>
private readonly IEmailSender emailSender;
/// <summary>
/// The running environment.
/// </summary>
private readonly IRunningEnvironment runningEnvironment;
/// <summary>
/// The exception filter.
/// </summary>
/// <param name="exceptionLogServices">
/// The exception log services.
/// </param>
/// <param name="emailSender">
/// The email sender.
/// </param>
/// <param>
/// <param name="runningEnvironment">
/// The running environment.
/// </param>
public ExceptionFilter(IExceptionLogService exceptionLogServices, IEmailSender emailSender, IRunningEnvironment runningEnvironment)
{
this.exceptionLogServices = exceptionLogServices;
this.emailSender = emailSender;
this.runningEnvironment = runningEnvironment;
}
/// <inheritdoc />
public async void OnException(ExceptionContext context)
{
var logFrom = context.ActionDescriptor.DisplayName;
var logRoute = context.ActionDescriptor.AttributeRouteInfo.Template;
var errorMessage = context.Exception.InnerException != null ? context.Exception.InnerException.Message : context.Exception.Message;
var errorDescription = JsonConvert.SerializeObject(context.Exception.StackTrace);
this.exceptionLogServices.Invoke(logFrom, logRoute, errorMessage, errorDescription);
const HttpStatusCode status = HttpStatusCode.InternalServerError;
context.ExceptionHandled = true;
var response = context.HttpContext.Response;
response.StatusCode = (int)status;
response.ContentType = "application/json";
await response.WriteAsync(context.Exception.StackTrace);
if (this.runningEnvironment.CurrentEnvironment != "Local")
{
var userList = new List<AccountModel> { };
if (this.runningEnvironment.CurrentEnvironment == "Production")
{
userList.Add(new AccountModel { Email = "puday@sujainfo.net", FullName = "Uday" });
userList.Add(new AccountModel { Email = "vikas@docassistant.net", FullName = "Vikas Kuchimanchi" });
}
else
{
userList.Add(new AccountModel { Email = "kjaishree@sujainfo.net", FullName = "Jaishree" });
userList.Add(new AccountModel { Email = "psravani@sujainfo.net", FullName = "Sravani" });
}
var errorMessageWithEnvironment = $@" Exception occur in {this.runningEnvironment.CurrentEnvironment} : {Environment.NewLine} {errorMessage}";
await this.emailSender.SendExceptionLogEmailToSupport(userList, logFrom, errorMessageWithEnvironment);
}
}
}
}
namespace Hims.Api.Filters
{
using System;
using System.Collections.Generic;
/// <summary>
/// Policy Selector With Label
/// </summary>
/// <typeparam name="T">The entity</typeparam>
public class PolicySelectorWithLabel<T> where T : Attribute
{
/// <summary>
/// Gets or sets the selector.
/// </summary>
public Func<IEnumerable<T>, IEnumerable<string>> Selector { get; set; }
/// <summary>
/// Gets or sets the label.
/// </summary>
public string Label { get; set; }
}
}
This diff is collapsed.
namespace Hims.Api.Helper
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hims.Domain.Helpers;
using Hims.Domain.Services;
using Hims.Shared.EntityModels;
using Hims.Shared.Library.Enums;
/// <summary>
/// The notification helper.
/// </summary>
public static class NotificationHelper
{
/// <summary>
/// The notification helper.
/// </summary>
/// <param name="providerOrPatientId">
/// The provider Or Patient Id.
/// </param>
/// <param name="role">
/// The role.
/// </param>
/// <param name="intimate">
/// The intimate.
/// </param>
/// <param name="id">
/// The id.
/// </param>
/// <param name="accountSessionServices">
/// The account Session Services.
/// </param>
/// <param name="pushNotificationHelper">
/// The push Notification Helper.
/// </param>
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
public static async Task<bool> Notification(
int providerOrPatientId,
Roles role,
NotificationIntimate intimate,
string id,
IAccountSessionService accountSessionServices,
IPushNotificationHelper pushNotificationHelper)
{
var message = string.Empty;
var type = string.Empty;
switch (intimate)
{
case NotificationIntimate.PrescriptionAdded:
message = "Doctor has added prescription";
type = "UpdateOnPrescription";
break;
case NotificationIntimate.PrescriptionUpdated:
message = "Doctor has updated prescription";
type = "UpdateOnPrescription";
break;
case NotificationIntimate.FullTranscriptionAdded:
message = "Doctor has added full transcription";
type = "UpdateOnFullTranscription";
break;
case NotificationIntimate.FullTranscriptionUpdated:
message = "Doctor has updated full transcription";
type = "UpdateOnFullTranscription";
break;
case NotificationIntimate.DoctorUploadedDocuments:
message = "Doctor has uploaded document(s)";
type = "UpdateOnUploadedDocuments";
break;
case NotificationIntimate.DoctorEditedDocuments:
message = "Doctor has edited document(s)";
type = "UpdateOnEditedDocuments";
break;
case NotificationIntimate.PatientUploadedDocuments:
message = "Patient has uploaded document(s)";
type = "UpdateOnUploadedDocuments";
break;
case NotificationIntimate.PatientEditedDocuments:
message = "Patient has edited document(s)";
type = "UpdateOnEditedDocuments";
break;
}
if (role == Roles.Provider)
{
var accountSessionProviderModel = await accountSessionServices.FetchDeviceTokenAsync(providerOrPatientId, Roles.Provider);
var sessionProviderModel = accountSessionProviderModel as AccountSessionModel[] ?? accountSessionProviderModel.ToArray();
if (sessionProviderModel.Any())
{
var deviceTokenForProviderAndroid = sessionProviderModel.Where(d => d.DeviceType == 2).Select(s => s.DeviceToken).ToList();
var deviceTokenForProviderIOS = sessionProviderModel.Where(d => d.DeviceType == 3).Select(s => s.DeviceToken).ToList();
if (deviceTokenForProviderAndroid != null)
{
await pushNotificationHelper.IntimateAsync(
"Hims",
message,
type,
deviceTokenForProviderAndroid,
new List<string>(),
id);
}
if (deviceTokenForProviderIOS != null)
{
await pushNotificationHelper.IntimateAsync(
"Hims",
message,
type,
new List<string>(),
deviceTokenForProviderIOS,
id);
}
}
}
if (role == Roles.Patient)
{
var accountSessionPatientModel = await accountSessionServices.FetchDeviceTokenAsync(providerOrPatientId, Roles.Patient);
var accountSessionModels = accountSessionPatientModel as AccountSessionModel[] ?? accountSessionPatientModel.ToArray();
if (accountSessionModels.Any())
{
var deviceTokenForProviderAndroid = accountSessionModels.Where(d => d.DeviceType == 2).Select(s => s.DeviceToken).ToList();
var deviceTokenForProviderIOS = accountSessionModels.Where(d => d.DeviceType == 3).Select(s => s.DeviceToken).ToList();
if (deviceTokenForProviderAndroid != null)
{
await pushNotificationHelper.IntimateAsync(
"Hims",
message,
type,
deviceTokenForProviderAndroid,
new List<string>(),
id);
}
if (deviceTokenForProviderIOS != null)
{
await pushNotificationHelper.IntimateAsync(
"Hims",
message,
type,
new List<string>(),
deviceTokenForProviderIOS,
id);
}
}
}
return true;
}
}
}
namespace Hims.Api.Helper
{
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using Hims.Domain.Services;
/// <summary>
/// The payment helper.
/// </summary>
public static class PaymentHelper
{
/// <summary>
/// The generate check sum hash.
/// </summary>
/// <param name="text">
/// The text.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string GenerateCheckSumHash(string text)
{
var message = Encoding.UTF8.GetBytes(text);
var hashString = new SHA256Managed();
var hashValue = hashString.ComputeHash(message);
return hashValue.Aggregate(string.Empty, (current, x) => current + $"{x:x2}");
}
/// <summary>
/// The generate hash.
/// </summary>
/// <param name="text">
/// The text.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string GenerateHash(string text)
{
var message = Encoding.UTF8.GetBytes(text);
var hashString = new SHA512Managed();
var hashValue = hashString.ComputeHash(message);
return hashValue.Aggregate(string.Empty, (current, x) => current + $"{x:x2}");
}
///// <summary>
///// The generate transaction id.
///// </summary>
///// <returns>
///// The <see cref="string"/>.
///// </returns>
//public static string GenerateTransactionId()
//{
// var rnd = new Random();
// var strHash = GenerateHash(rnd.ToString() + DateTime.UtcNow);
// return strHash.Substring(0, 20);
//}
/// <summary>
/// The generate transaction id.
/// </summary>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string GetVouherNumber(IAppointmentTransactionService appointmentTransactionsServices)
{
// var previous = unitOfWork.Current.QuerySingleOrDefaultAsync<string>($@"select ""VoucherNumber"" from ""AppointmentTransaction"" order by ""AppointmentTransactionId"" desc limit 1");
var previousVoucherNo = appointmentTransactionsServices.GetPreviousVoucherNumberAsync();
if (previousVoucherNo == null)
{
return $@"{DateTime.Now.ToString("dd/MM/yy")}/10001";
}
else
{
var preVoucherno = previousVoucherNo.ToString(); // converting in string
var prevoucherdate = preVoucherno.Substring(0, Math.Min(preVoucherno.Length, 8)); //DateTime in string
if (prevoucherdate != DateTime.Now.ToString("dd/MM/yy"))
{
return $@"{DateTime.Now.ToString("dd/MM/yy")}/10001"; // start seq for new date .
}
else
{
var presequenceNo = preVoucherno.Substring(preVoucherno.Length - 5); // increment seq for same date .
return $@"{DateTime.Now.ToString("dd/MM/yy")}/{Convert.ToInt64(presequenceNo) + 1}";
}
}
}
}
}
using Hims.Shared.UserModels.NurseShift;
using System;
namespace Hims.Api.Helper
{
public static class ProgressReportHelper
{
/// <summary>
/// Gets the current day identifier.
/// </summary>
/// <returns></returns>
public static int GetCurrentDayId()
{
var currentHour = DateTime.Now.Hour;
// 1 = Morning
// 11 = After Morning Before Afternoon
// 2 = Afternoon
// 12 = After Afternoon before Night
// 3 = Night
// 4 = After Night
var currentDayId = currentHour < 6
? 0
: currentHour >= 6 && currentHour <= 9
? 1
: currentHour > 9 && currentHour < 12
? 11
: currentHour >= 12 && currentHour <= 14
? 2
: currentHour > 14 && currentHour < 19
? 12
: currentHour >= 19 && currentHour <= 21
? 3
: 4;
return currentDayId;
}
/// <summary>
/// Gets the current day identifier.
/// </summary>
/// <returns></returns>
public static double GetCurrentDayIdAlt()
{
var currentHour = DateTime.Now.Hour;
// 1 = Morning
// 11 = After Morning Before Afternoon
// 2 = Afternoon
// 12 = After Afternoon before Night
// 3 = Night
// 4 = After Night
var currentDayId = currentHour < 6
? 0
: currentHour >= 6 && currentHour <= 9
? 1
: currentHour > 9 && currentHour < 12
? 1.1
: currentHour >= 12 && currentHour <= 14
? 2
: currentHour > 14 && currentHour < 19
? 2.1
: currentHour >= 19 && currentHour <= 21
? 3
: 4;
return currentDayId;
}
/// <summary>
/// Gets the default times.
/// </summary>
/// <returns></returns>
public static TimeModel GetDefaultTimes()
{
return new TimeModel
{
Morning = new TimeModelHelper
{
Hour = 8,
Minute = 0
},
Afternoon = new TimeModelHelper
{
Hour = 13,
Minute = 0
},
Night = new TimeModelHelper
{
Hour = 20,
Minute = 0
}
};
}
}
}
namespace Hims.Api.Hubs
{
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
/// <summary>
/// The communication hub.
/// </summary>
public class CommunicationHub : Hub
{
/// <summary>
/// The communication.
/// </summary>
/// <param name="model">
/// The model.
/// </param>
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
public async Task CommunicationGlobal(CommunicationMessage model)
{
await Clients.Others.SendAsync("CommunicationGlobal", model).ConfigureAwait(false);
}
/// <summary>
/// The send to group.
/// </summary>
/// <param name="model">
/// The model.
/// </param>
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
public async Task CommunicationGroup(CommunicationMessageAlt model)
{
await Clients.OthersInGroup(model.GroupName).SendAsync("CommunicationGroup", model).ConfigureAwait(false);
}
/// <summary>
/// The subscribe individual communication.
/// </summary>
/// <param name="groupName">
/// The group name.
/// </param>
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
public async Task SubscribeToGroup(string groupName)
{
await Groups.AddToGroupAsync(Context.ConnectionId, groupName).ConfigureAwait(false);
}
/// <summary>
/// The unsubscribe individual communication.
/// </summary>
/// <param name="groupName">
/// The group name.
/// </param>
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
public async Task UnsubscribeToGroup(string groupName)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName).ConfigureAwait(false);
}
}
}
namespace Hims.Api.Hubs
{
using System;
/// <summary>
/// The communication type.
/// </summary>
public enum CommunicationType
{
/// <summary>
/// The call.
/// </summary>
Call = 1,
/// <summary>
/// The notify.
/// </summary>
Notify = 2,
/// <summary>
/// The reject.
/// </summary>
Reject = 3,
/// <summary>
/// The intimate alt one.
/// </summary>
CloseAll = 4,
/// <summary>
/// The intimate alt one.
/// </summary>
Join = 5,
/// <summary>
/// The intimate alt one.
/// </summary>
Close = 6,
/// <summary>
/// The appointment refresh.
/// </summary>
AppointmentRefresh = 7,
/// <summary>
/// The appointment add refresh.
/// </summary>
AppointmentAddRefresh = 8,
/// <summary>
/// The message refresh.
/// </summary>
MessageRefresh = 9,
/// <summary>
/// The cancel.
/// </summary>
Cancel = 10,
/// <summary>
/// The video initiate
/// </summary>
Initiate = 11,
/// <summary>
/// The external join
/// </summary>
ExternalJoin = 12
}
/// <summary>
/// The communication message.
/// </summary>
public class CommunicationMessage
{
/// <summary>
/// Gets or sets the type.
/// </summary>
public CommunicationType Type { get; set; }
/// <summary>
/// Gets or sets the unique id.
/// </summary>
public string UniqueId { get; set; }
/// <summary>
/// Gets or sets the user unique id.
/// </summary>
public string UserUniqueId { get; set; }
/// <summary>
/// Gets or sets the main eid.
/// </summary>
public string MainEid { get; set; }
/// <summary>
/// Gets or sets the main id.
/// </summary>
public int MainId { get; set; }
/// <summary>
/// Gets or sets the main id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the main id.
/// </summary>
public int CallerId { get; set; }
/// <summary>
/// Gets or sets the message.
/// </summary>
public string Message { get; set; }
/// <summary>
/// Gets or sets the content.
/// </summary>
public string Content { get; set; }
/// <summary>
/// Gets or sets the date.
/// </summary>
public DateTimeOffset? Date { get; set; }
/// <summary>
/// Gets or sets the is creating.
/// </summary>
public bool? IsCreating { get; set; }
/// <summary>
/// Gets or sets the is creating.
/// </summary>
public int TelemedicineId { get; set; }
public bool StartAudioOnly { get; internal set; }
public int RoleId { get; internal set; }
public int NotifyToId { get; internal set; }
public string ClientName { get; internal set; }
}
public class CommunicationMessageAlt
{
/// <summary>
/// Gets or sets the type.
/// </summary>
public int Type { get; set; }
/// <summary>
/// Gets or sets the group name.
/// </summary>
public string GroupName { get; set; }
public string? CubicleName { get; set; }
public string PatientName { get; set; }
public int TokenNumber { get; set; }
}
}
namespace Hims.Api.Listeners
{
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using Microsoft.Extensions.Configuration;
/// <summary>
/// The daily trace listener.
/// </summary>
public sealed class DailyTraceListener : TraceListener
{
/// <summary>
/// Initializes a new instance of the <see cref="DailyTraceListener"/> class.
/// </summary>
/// <param name="configuration">
/// The configuration.
/// </param>
public DailyTraceListener(IConfiguration configuration) => this.LogFolder = configuration.GetValue<string>("Directories:ErrorLogs");
/// <summary>
/// Gets or sets a value indicating whether use UTC time.
/// </summary>
private bool UseUtcTime { get; set; }
/// <summary>
/// Gets or sets the log folder.
/// </summary>
private string LogFolder { get; set; }
/// <summary>
/// Gets or sets a value indicating whether disposed.
/// </summary>
private bool Disposed { get; set; }
/// <summary>
/// Gets or sets a value indicating whether has header.
/// </summary>
private bool HasHeader { get; set; }
/// <summary>
/// Gets or sets the current log file path.
/// </summary>
private string CurrentLogFilePath { get; set; }
/// <summary>
/// Gets or sets the current log date.
/// </summary>
private DateTime? CurrentLogDate { get; set; }
/// <summary>
/// Gets or sets the log file stream.
/// </summary>
private FileStream LogFileStream { get; set; }
/// <summary>
/// Gets or sets the log file writer.
/// </summary>
private StreamWriter LogFileWriter { get; set; }
/// <summary>
/// Gets or sets the log locker.
/// </summary>
private SemaphoreSlim LogLocker { get; set; } = new SemaphoreSlim(1, 1);
/// <summary>
/// The use UTC.
/// </summary>
/// <returns>
/// The <see cref="DailyTraceListener"/>.
/// </returns>
public DailyTraceListener UseUtc()
{
this.UseUtcTime = true;
return this;
}
/// <summary>
/// The use header.
/// </summary>
/// <returns>
/// The <see cref="DailyTraceListener"/>.
/// </returns>
public DailyTraceListener UseHeader()
{
this.HasHeader = true;
return this;
}
/// <summary>
/// The invoke.
/// </summary>
/// <param name="from">
/// The from.
/// </param>
/// <param name="route">
/// The route.
/// </param>
/// <param name="message">
/// The message.
/// </param>
/// <param name="description">
/// The description.
/// </param>
public void Invoke(string from, string route, string message, string description)
{
var time = this.FormatTime(this.GetCurrentTime());
this.WriteLine($"{time},{EscapeCsv(from)},{EscapeCsv(route)},{EscapeCsv(message)},{EscapeCsv(description)}");
}
/// <summary>
/// The write.
/// </summary>
/// <param name="message">
/// The message.
/// </param>
public override void Write(string message)
{
try
{
this.LogLocker.Wait();
this.CheckDisposed();
this.CheckFile();
this.LogFileWriter.Write(message);
this.LogFileWriter.Flush();
}
catch (Exception ex)
{
Trace.TraceError(ex.ToString());
}
finally
{
this.LogLocker.Release();
}
}
/// <summary>
/// The write line.
/// </summary>
/// <param name="message">
/// The message.
/// </param>
public override void WriteLine(string message)
{
this.Write(message + Environment.NewLine);
}
/// <summary>
/// The dispose.
/// </summary>
/// <param name="disposing">
/// The disposing.
/// </param>
protected override void Dispose(bool disposing)
{
this.Disposed = true;
try
{
this.LogFileWriter?.Dispose();
this.LogFileStream?.Dispose();
this.LogLocker.Dispose();
}
catch (Exception ex)
{
Trace.TraceError(ex.ToString());
}
base.Dispose(disposing);
}
/// <summary>
/// The escape CSV.
/// </summary>
/// <param name="input">
/// The input.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
private static string EscapeCsv(string input)
{
for (var i = 0; i < input.Length; i++)
{
if (input[i] != ',' && input[i] != '\n')
{
continue;
}
input = input.Replace("\"", "\"\"");
return $"\"{input}\"";
}
return input;
}
/// <summary>
/// The write header.
/// </summary>
private void WriteHeader()
{
this.LogFileWriter.WriteLine("Time,From,Router,Message,Description");
}
/// <summary>
/// The format time.
/// </summary>
/// <param name="time">
/// The time.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
private string FormatTime(DateTime time) => time.ToString("o");
/// <summary>
/// The get current time.
/// </summary>
/// <returns>
/// The <see cref="DateTime"/>.
/// </returns>
private DateTime GetCurrentTime() => this.UseUtcTime ? DateTime.UtcNow : DateTime.Now;
/// <summary>
/// The initialize log file.
/// </summary>
private void InitializeLogFile()
{
this.CheckDisposed();
try
{
this.LogFileWriter?.Dispose();
if (this.LogFileStream != null)
{
var logFileWriter = this.LogFileWriter;
logFileWriter?.Dispose();
}
}
catch (Exception ex)
{
Trace.TraceError(ex.ToString());
}
var currentTime = this.GetCurrentTime();
var fileName = $"{currentTime:yyyy-MM-dd}.log";
this.CurrentLogFilePath = Path.Combine(this.LogFolder, fileName);
// Ensure the folder is there
Directory.CreateDirectory(this.LogFolder);
// Create/Open log file
this.LogFileStream = new FileStream(this.CurrentLogFilePath, FileMode.Append);
this.LogFileWriter = new StreamWriter(this.LogFileStream);
// Write Header if needed
if (this.LogFileStream.Length == 0 && this.HasHeader)
{
this.WriteHeader();
}
}
/// <summary>
/// The check file.
/// </summary>
private void CheckFile()
{
this.CheckDisposed();
var currentTime = this.GetCurrentTime();
if (this.CurrentLogDate != null && currentTime.Date == this.CurrentLogDate)
{
return;
}
this.InitializeLogFile();
this.CurrentLogDate = currentTime.Date;
}
/// <summary>
/// The check disposed.
/// </summary>
private void CheckDisposed()
{
if (this.Disposed)
{
throw new InvalidOperationException("The Trace Listener is Disposed.");
}
}
}
}
namespace Hims.Api.Middleware
{
using IdentityModel;
using IdentityServer4.AccessTokenValidation;
using Infrastructure.Configurations;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Services;
using Validators;
/// <summary>
/// The authentication middleware.
/// </summary>
public class AuthenticationMiddleware
{
/// <summary>
/// Configures the authorization.
/// </summary>
/// <param name="services">
/// The services.
/// </param>
/// <param name="configuration">
/// The configuration.
/// </param>
public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
var identityServerConfiguration = configuration.GetSection("IdentityServerConfiguration").Get<IdentityServerConfiguration>();
var connectionString = configuration.GetConnectionString("Connection");
var migrationsAssembly = typeof(Startup).Assembly.GetName().Name;
services.AddIdentityServer(options =>
{
options.Events.RaiseErrorEvents = true;
options.Events.RaiseInformationEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseSuccessEvents = true;
options.EmitStaticAudienceClaim = true;
})
.AddDeveloperSigningCredential()
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = b => b.UseNpgsql(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
})
.AddOperationalStore(options =>
{
options.ConfigureDbContext = b => b.UseNpgsql(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
options.EnableTokenCleanup = true;
})
.AddProfileService<ProfileServices>()
.AddResourceOwnerValidator<ResourceOwnerPasswordValidator>();
services
.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(
IdentityServerAuthenticationDefaults.AuthenticationScheme,
referenceOptions =>
{
referenceOptions.Authority = identityServerConfiguration.Authority;
referenceOptions.RequireHttpsMetadata = false;
referenceOptions.ApiName = identityServerConfiguration.ApiName;
referenceOptions.ApiSecret = identityServerConfiguration.ApiSecret;
referenceOptions.RoleClaimType = JwtClaimTypes.Role;
});
services.AddAuthorization(
options =>
{
options.AddPolicy("Everyone", policy => { policy.RequireRole("SuperAdmin", "Administrator", "Patient", "Provider"); });
options.AddPolicy("OnlyAdmins", policy => { policy.RequireRole("Administrator", "SuperAdmin"); });
options.AddPolicy("OnlySuperAdmin", policy => { policy.RequireRole("SuperAdmin"); });
options.AddPolicy("Patient", policy => { policy.RequireRole("Patient"); });
options.AddPolicy("Provider", policy => { policy.RequireRole("Provider"); });
});
}
/// <summary>
/// The configure.
/// </summary>
/// <param name="app">
/// The app.
/// </param>
public static void Configure(IApplicationBuilder app)
{
app.UseAuthentication();
app.UseIdentityServer();
}
}
}
\ No newline at end of file
namespace Hims.Api.Middleware
{
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Filters;
using Infrastructure.Configurations;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerUI;
/// <summary>
/// Swagger API documentation components start-up configuration
/// </summary>
public class SwaggerMiddleware
{
/// <summary>
/// Configures the service.
/// </summary>
/// <param name="services">
/// The services.
/// </param>
/// <param name="configuration">
/// The configuration.
/// </param>
public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
var appConfiguration = configuration.GetSection("ApplicationConfiguration").Get<ApplicationConfiguration>();
services.AddSwaggerGen(options =>
{
options.CustomSchemaIds( type => type.ToString() );
options.SwaggerDoc(
"v" + appConfiguration.Version,
new OpenApiInfo
{
Version = "v" + appConfiguration.Version,
Title = "Careaxes Rest API"
});
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Api.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Domain.Configurations.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Domain.Helpers.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Domain.Repositories.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Domain.Services.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Shared.DataFilters.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Shared.EntityModels.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Shared.Library.xml"));
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Hims.Shared.UserModels.xml"));
options.IgnoreObsoleteActions();
options.IgnoreObsoleteProperties();
options.DescribeAllParametersInCamelCase();
options.UseInlineDefinitionsForEnums();
options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
options.AddSecurityDefinition(
"Bearer",
new OpenApiSecurityScheme
{
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Description = "Careaxes Rest API Authorization header using the Bearer scheme. Example: \"Bearer {token}\""
});
options.OperationFilter<SecurityRequirementsOperationFilter>();
options.OperationFilter<AppendAuthorizeToSummaryOperationFilter>();
});
}
/// <summary>
/// Configures the specified application.
/// </summary>
/// <param name="app">
/// The application.
/// </param>
/// <param name="configuration">
/// The configuration.
/// </param>
/// <param name="assembly">
/// The assembly.
/// </param>
public static void Configure(IApplicationBuilder app, IConfiguration configuration, Assembly assembly)
{
var appConfiguration = configuration.GetSection("ApplicationConfiguration").Get<ApplicationConfiguration>();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.IndexStream = () => assembly.GetManifestResourceStream("Hims.Api.Swagger.index.html");
// Core
c.SwaggerEndpoint(appConfiguration.BaseUrl + "/swagger" + "/v" + appConfiguration.Version + "/swagger.json", "Careaxes Rest API v" + appConfiguration.Version + " Documentation");
// Display
c.DefaultModelsExpandDepth(0);
c.DefaultModelRendering(ModelRendering.Example);
c.DisplayRequestDuration();
c.DocExpansion(DocExpansion.List);
c.EnableDeepLinking();
c.EnableFilter();
c.ShowExtensions();
c.DocumentTitle = "Careaxes Rest API";
c.RoutePrefix = "api-docs";
c.InjectStylesheet(appConfiguration.BaseUrl + "/assets/css/swagger.css");
c.InjectJavascript(appConfiguration.BaseUrl + "/assets/js/jquery.min.js");
c.InjectJavascript(appConfiguration.BaseUrl + "/assets/js/swagger.js");
c.EnableFilter();
c.ShowExtensions();
// Network
c.SupportedSubmitMethods(SubmitMethod.Post, SubmitMethod.Get, SubmitMethod.Put, SubmitMethod.Delete);
});
}
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The acccount location model.
/// </summary>
public class AccountLocationModel
{
/// <summary>
/// Gets or sets the location ids.
/// </summary>
/// <value>
/// The location ids.
/// </value>
public int[] LocationIds { get; set; }
/// <summary>
/// Gets or sets the account identifier.
/// </summary>
/// <value>
/// The account identifier.
/// </value>
public int AccountId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The agreement status request.
/// </summary>
public class AgreementStatusRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The change password request.
/// </summary>
public class ChangePasswordRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the account id.
/// </summary>
public string EncryptedAccountId { get; set; }
/// <summary>
/// Gets or sets the password.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Gets or sets the role Id.
/// </summary>
public int? RoleId { get; set; }
/// <summary>
/// Gets or sets the user name.
/// </summary>
public string UserName { get; set; }
/// <summary>
/// Gets or sets the user name.
/// </summary>
public int LocationId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
using Shared.Library.Enums;
/// <summary>
/// The create session request.
/// </summary>
public class CreateSessionRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the device key.
/// </summary>
public string DeviceToken { get; set; }
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType DeviceType { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
public string Description { get; set; }
}
}
\ No newline at end of file
namespace Hims.Api.Models.Account
{
/// <summary>
/// The fetch sessions request.
/// </summary>
public class FetchSessionsRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The find request.
/// </summary>
public class FindRequest
{
/// <summary>
/// Gets or sets a value indicating whether is reset.
/// </summary>
public bool IsReset { get; set; }
/// <summary>
/// Gets or sets the account id.
/// </summary>
public string EncryptedId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
using Shared.Library.Enums;
/// <summary>
/// The find session request.
/// </summary>
public class FindSessionRequest
{
/// <summary>
/// Gets or sets the session id.
/// </summary>
public int SessionId { get; set; }
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType? DeviceType { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.Account
{
using System.Collections.Generic;
using Shared.Library.Enums;
/// <summary>
/// The forgot password request.
/// </summary>
public class ForgotPasswordRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the mobile.
/// </summary>
public string Username { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the password.
/// </summary>
public string? Password { get; set; }
/// <summary>
/// Gets or sets the role Id.
/// </summary>
public int? RoleId { get; set; }
/// <summary>
/// Gets or sets the mobile.
/// </summary>
public string Mobile { get; set; }
/// <summary>
/// Gets or sets the account types.
/// </summary>
public IEnumerable<AccountType> AccountTypes { get; set; } = new List<AccountType>();
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The get preference request.
/// </summary>
public class GetPreferenceRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
}
}
\ No newline at end of file
namespace Hims.Api.Models.Account
{
/// <summary>
/// The kill all sessions request.
/// </summary>
public class KillAllSessionsRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
}
}
\ No newline at end of file
namespace Hims.Api.Models.Account
{
/// <summary>
/// The kill all sessions request.
/// </summary>
public class KillOtherSessionsRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>Gets or sets the current device id.</summary>
public string CurrentDeviceId { get; set; }
}
}
\ No newline at end of file
#nullable enable
namespace Hims.Api.Models.Account
{
using Shared.Library.Enums;
/// <summary>
/// The kill session request.
/// </summary>
public class KillSessionRequest
{
/// <summary>
/// Gets or sets the accountId id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType? DeviceType { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
public string? DeviceId { get; set; }
/// <summary>Gets or sets the device token.</summary>
public string? DeviceToken { get; set; }
/// <summary>Gets or sets the is other device.</summary>
public bool? IsOtherDevice { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.Account
{
using System.Collections.Generic;
using Shared.Library.Enums;
/// <summary>
/// The login OTP request.
/// </summary>
public class LoginOTPRequest
{
/// <summary>
/// Gets or sets the email/mobile.
/// </summary>
public string Username { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the country id.
/// </summary>
public int? CountryId { get; set; }
/// <summary>
/// Gets or sets the account types.
/// </summary>
public IEnumerable<AccountType> AccountTypes { get; set; } = new List<AccountType>();
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType DeviceType { get; set; }
/// <summary>
/// Gets or sets the device key.
/// </summary>
public string? DeviceToken { get; set; }
/// <summary>
/// Gets or sets the device ID.
/// </summary>
public string? DeviceId { get; set; }
/// <summary>
/// Gets or sets the account ID.
/// </summary>
public int? AccountId { get; set; }
public int? PatientId { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.Account
{
using System.Collections.Generic;
using Shared.Library.Enums;
/// <summary>
/// The login request.
/// </summary>
public class LoginRequest
{
/// <summary>
/// Gets or sets the username.
/// </summary>
public string Username { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the password.
/// </summary>
public string Password { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the account types.
/// </summary>
public IEnumerable<AccountType> AccountTypes { get; set; } = new List<AccountType>();
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType DeviceType { get; set; }
/// <summary>
/// Gets or sets the device key.
/// </summary>
public string? DeviceToken { get; set; }
/// <summary>
/// Gets or sets the device ID.
/// </summary>
public string? DeviceId { get; set; }
/// <summary>
/// Gets or sets the location identifier.
/// </summary>
/// <value>
/// The location identifier.
/// </value>
public int LocationId { get; set; }
/// <summary>
/// Gets or sets the device ID.
/// </summary>
public string? EncryptedAccountId { get; set; }
/// <summary>
/// Gets or sets the mobile.
/// </summary>
public string Mobile { get; set; }
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int? AccountId { get; set; }
public int? PatientId { get; set; }
}
}
\ No newline at end of file
#nullable enable
namespace Hims.Api.Models.Account
{
using Shared.Library.Enums;
/// <summary>
/// The logout request.
/// </summary>
public class LogoutRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType DeviceType { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
public string? DeviceId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The mail request.
/// </summary>
public class MailRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The mail request.
/// </summary>
public class MenuRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the role identifier.
/// </summary>
/// <value>
/// The role identifier.
/// </value>
public int RoleId { get; set; }
}
}
namespace Hims.Api.Models.Account
{
/// <summary>
/// The modify status request.
/// </summary>
public class ModifyStatusRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether status.
/// </summary>
public bool Status { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public int ModifiedBy { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.Account
{
using System.Collections.Generic;
using Shared.Library.Enums;
/// <summary>
/// The login request.
/// </summary>
public class ReferralRequest
{
/// <summary>
/// Gets or sets the username.
/// </summary>
public int PatientId { get; set; }
/// <summary>
/// Gets or sets the username.
/// </summary>
public string Username { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the username.
/// </summary>
public string FullName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the password.
/// </summary>
public int CountryId { get; set; }
/// <summary>
/// Gets or sets the password.
/// </summary>
public string ReferralCode { get; set; } = string.Empty;
}
}
\ No newline at end of file
namespace Hims.Api.Models.Account
{
/// <summary>
/// The refresh authentication request.
/// </summary>
public class RefreshAuthenticationRequest
{
/// <summary>
/// Gets or sets the refresh token.
/// </summary>
public string Token { get; set; }
}
}
\ No newline at end of file
#nullable enable
namespace Hims.Api.Models.Account
{
using System.Collections.Generic;
using Shared.Library.Enums;
/// <summary>
/// The verify OTP request.
/// </summary>
public class VerifyOTPRequest
{
/// <summary>
/// Gets or sets the account id.
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// Gets or sets the account types.
/// </summary>
public IEnumerable<AccountType> AccountTypes { get; set; } = new List<AccountType>();
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType DeviceType { get; set; }
/// <summary>
/// Gets or sets the device key.
/// </summary>
public string? DeviceToken { get; set; }
/// <summary>
/// Gets or sets the device ID.
/// </summary>
public string? DeviceId { get; set; }
}
}
\ No newline at end of file
namespace Hims.Api.Models.Application
{
using Shared.Library.Enums;
/// <summary>
/// The send otp to email request.
/// </summary>
public class SendOTPToEmailRequest
{
/// <summary>
/// Gets or sets the account type.
/// </summary>
public AccountType? AccountType { get; set; }
/// <summary>
/// Gets or sets the email.
/// </summary>
public string Email { get; set; }
}
}
namespace Hims.Api.Models.Application
{
using Shared.Library.Enums;
/// <summary>
/// The send otp to mobile request.
/// </summary>
public class SendOTPToMobileRequest
{
/// <summary>
/// Gets or sets the account type.
/// </summary>
public AccountType? AccountType { get; set; }
/// <summary>
/// Gets or sets the mobile.
/// </summary>
public string Mobile { get; set; }
}
}
namespace Hims.Api.Models.Application
{
using System.Collections.Generic;
using Shared.Library.Enums;
/// <summary>
/// The verify email otp request.
/// </summary>
public class VerifyEmailOTPRequest
{
/// <summary>
/// Gets or sets the account types.
/// </summary>
public IEnumerable<AccountType> AccountTypes { get; set; }
/// <summary>
/// Gets or sets the email.
/// </summary>
public string Email { get; set; }
/// <summary>
/// Gets or sets the OTP.
/// </summary>
public string OTP { get; set; }
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType DeviceType { get; set; }
/// <summary>
/// Gets or sets the device key.
/// </summary>
public string DeviceToken { get; set; }
/// <summary>
/// Gets or sets the device Id.
/// </summary>
public string DeviceId { get; set; }
}
}
namespace Hims.Api.Models.Application
{
using System.Collections.Generic;
using Shared.Library.Enums;
/// <summary>
/// The verify mobile otp request.
/// </summary>
public class VerifyMobileOTPRequest
{
/// <summary>
/// Gets or sets the account types.
/// </summary>
public IEnumerable<AccountType> AccountTypes { get; set; }
/// <summary>
/// Gets or sets the mobile.
/// </summary>
public string Mobile { get; set; }
/// <summary>
/// Gets or sets the country id.
/// </summary>
public int CountryId { get; set; }
/// <summary>
/// Gets or sets the OTP.
/// </summary>
public string OTP { get; set; }
/// <summary>
/// Gets or sets the device type.
/// </summary>
public DeviceType DeviceType { get; set; }
/// <summary>
/// Gets or sets the device key.
/// </summary>
public string DeviceToken { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
public string DeviceId { get; set; }
}
}
namespace Hims.Api.Models.Appointment
{
/// <summary> The appointment request model.</summary>
public class AppointmentRequestModel
{
/// <summary>Gets or sets the appointment date.</summary>
public string AppointmentDate { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.Appointment
{
/// <summary>
/// The call history request.
/// </summary>
public class CallHistoryRequest
{
/// <summary>
/// Gets or sets the appointment id.
/// </summary>
public int AppointmentId { get; set; }
/// <summary>
/// Gets or sets the appointment id.
/// </summary>
public int TelemedicineId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether is first time.
/// </summary>
public bool IsFirstTime { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.Appointment
{
using System;
/// <summary>
/// The reschedule appointment request.
/// </summary>
public class ConfirmAppointmentRequest
{
/// <summary>
/// Gets or sets the appointment id.
/// </summary>
public int AppointmentId { get; set; }
/// <summary>
/// Gets or sets the appointment date.
/// </summary>
public string Delay { get; set; }
}
}
namespace Hims.Api.Models.Appointment
{
/// <summary>
/// Find appointment request model
/// </summary>
public class FetchAppointmentNumbersRequest
{
/// <summary>
/// Gets or sets the provider id.
/// </summary>
public int? ProviderId { get; set; }
/// <summary>
/// Gets or sets the practice id.
/// </summary>
public int? PracticeId { get; set; }
}
}
\ No newline at end of file
namespace Hims.Api.Models.Appointment
{
/// <summary>
/// Find appointment request model
/// </summary>
public class FindAppointmentRequest
{
/// <summary>
/// Gets or sets the appointment id.
/// </summary>
public int AppointmentId { get; set; }
/// <summary>
/// Gets or sets the encrypted appointment id.
/// </summary>
public string EncryptedAppointmentId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is admission.
/// </summary>
/// <value>
/// <c>true</c> if this instance is admission; otherwise, <c>false</c>.
/// </value>
public bool IsAdmission { get; set; }
}
}
\ No newline at end of file
namespace Hims.Api.Models.Appointment
{
/// <summary>
/// The find appointment transaction request.
/// </summary>
public class FindAppointmentTransactionRequest
{
/// <summary>
/// Gets or sets the appointment transaction id.
/// </summary>
public int AppointmentTransactionId { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.Appointment
{
using System;
/// <summary>
/// The reschedule appointment request.
/// </summary>
public class RescheduleAppointmentRequest
{
/// <summary>
/// Gets or sets the appointment id.
/// </summary>
public int AppointmentId { get; set; }
/// <summary>
/// Gets or sets the appointment date.
/// </summary>
public DateTime AppointmentDate { get; set; }
/// <summary>
/// Gets or sets the appointment notes.
/// </summary>
public string? AppointmentNotes { get; set; }
/// <summary>
/// Gets or sets the appointment time.
/// </summary>
public string AppointmentTime { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the provider id.
/// </summary>
public int ProviderId { get; set; }
/// <summary>
/// Gets or sets the provider location id.
/// </summary>
public int ProviderLocationId { get; set; }
/// <summary>
/// Gets or sets the provider location id.
/// </summary>
public int ProviderAvailabilityId { get; set; }
/// <summary>
/// Gets or sets the provider location id.
/// </summary>
public int ConsultationTypeId { get; set; }
/// <summary>
/// Gets or sets the appointment end time.
/// </summary>
public string? AppointmentEndTime { get; set; }
/// <summary>
/// Gets or sets the department id.
/// </summary>
public int? DepartmentId { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public int ModifiedBy { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public short LogFrom { get; set; }
/// <summary>
/// Gets or sets the location identifier.
/// </summary>
/// <value>
/// The location identifier.
/// </value>
public int LocationId { get; set; }
/// <summary>
/// Gets or sets the token number.
/// </summary>
/// <value>
/// The token number.
/// </value>
public int TokenNumber { get; set; }
/// <summary>
/// Gets or sets the specialization id.
/// </summary>
public int? SpecializationId { get; set; }
/// <summary>
/// Gets or sets the appointment ids.
/// </summary>
public string? AppointmentIds { get; set; }
/// <summary>
/// Gets or sets the appointment timings.
/// </summary>
public string? AppointmentTimings {get; set;}
/// <summary>
/// Gets or sets the appoinment end timings.
/// </summary>
public string? AppointmentEndTimings { get; set; }
/// <summary>
/// Gets or sets the token numbers.
/// </summary>
public string? TokenNumbers { get; set; }
/// <summary>
/// Gets or sets the visit type id.
/// </summary>
public int? VisitTypeId { get; set; }
/// <summary>
/// Gets or sets the charge types id.
/// </summary>
public int? ChargeTypesId { get; set; }
/// <summary>
/// Gets or sets the amount.
/// </summary>
public decimal Amount { get; set; }
/// <summary>
/// Gets or sets the discount.
/// </summary>
public decimal Discount { get; set; }
/// <summary>
/// Gets or sets the total.
/// </summary>
public decimal Total { get; set; }
}
}
namespace Hims.Api.Models.Appointment
{
using System.Collections.Generic;
using Hims.Shared.UserModels;
/// <summary>
/// The call history request.
/// </summary>
public class TelemedicineHistory
{
/// <summary>
/// Gets or sets the telemedicine ids.
/// </summary>
public List<int> TelemedicineIds { get; set; }
/// <summary>
/// Gets or sets the call history.
/// </summary>
public List<CallHistoryModel> CallHistory { get; set; }
}
}
namespace Hims.Api.Models.Chat
{
/// <summary> The chat fetch request model.</summary>
public class ChatFetchRequestModel
{
/// <summary>Gets or sets the sender id.</summary>
public string SenderId { get; set; }
/// <summary>Gets or sets the sender type.</summary>
public string SenderType { get; set; }
/// <summary>Gets or sets the receiver id.</summary>
public string ReceiverId { get; set; }
/// <summary>Gets or sets the receiver type.</summary>
public string ReceiverType { get; set; }
/// <summary>Gets or sets the created date.</summary>
public string CreatedDate { get; set; }
}
}
namespace Hims.Api.Models.Chat
{
/// <summary> The chat request model.</summary>
public class ChatRequestModel
{
/// <summary>Gets or sets the chat id.</summary>
public int ChatId { get; set; }
/// <summary>Gets or sets the account id.</summary>
public int AccountId { get; set; }
}
}
namespace Hims.Api.Models.Chat
{
/// <summary> The push notification chat model.</summary>
public class PushNotificationChatModel
{
/// <summary>Gets or sets the sender id.</summary>
public int SenderId { get; set; }
/// <summary>Gets or sets the sender type.</summary>
public string SenderType { get; set; }
/// <summary>Gets or sets the receiver id.</summary>
public int ReceiverId { get; set; }
/// <summary>Gets or sets the receiver type.</summary>
public string ReceiverType { get; set; }
/// <summary>Gets or sets the message.</summary>
public string Message { get; set; }
/// <summary>Gets or sets the thumbnail.</summary>
public string Thumbnail { get; set; }
/// <summary>Gets or sets the name.</summary>
public string Name { get; set; }
}
}
namespace Hims.Api.Models.DentalEncounter
{
using System.Collections.Generic;
using Hims.Api.Models.InternalMedicine;
using Hims.Shared.Library.Enums;
/// <summary>
/// The dental encounter images.
/// </summary>
public class DentalEncounterImages
{
/// <summary>
/// Gets or sets the images.
/// </summary>
public List<SkinTypes> Images { get; set; }
/// <summary>
/// Gets or sets the json string.
/// </summary>
public string JsonString { get; set; }
/// <summary>
/// Gets or sets the encrypted appointment id.
/// </summary>
public string EncryptedAppointmentId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is admission.
/// </summary>
/// <value>
/// <c>true</c> if this instance is admission; otherwise, <c>false</c>.
/// </value>
public bool IsAdmission { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public int ModifiedBy { get; set; }
/// <summary>
/// Gets or sets the encounter id.
/// </summary>
public int? DentalEncounterId { get; set; }
/// <summary>
/// Gets or sets the encounter type.
/// </summary>
public DentalEncounterType Type { get; set; }
}
}
#nullable enable
namespace Hims.Api.Models.ExportFilters
{
/// <summary>
/// The appointment transaction filter model.
/// </summary>
public class PaymentExportFilterModel
{
/// <summary>
/// Gets or sets the provider id.
/// </summary>
public int? ProviderId { get; set; }
/// <summary>
/// Gets or sets the from date.
/// </summary>
public string? FromDate { get; set; }
/// <summary>
/// Gets or sets the to date.
/// </summary>
public string? ToDate { get; set; }
/// <summary>
/// Gets or sets the file name.
/// </summary>
public string FileName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the page index.
/// </summary>
public int PageIndex { get; set; }
/// <summary>
/// Gets or sets the page size.
/// </summary>
public int PageSize { get; set; }
}
}
namespace Hims.Api.Models.GynEncounter
{
using System.Collections.Generic;
using Hims.Shared.Library.Enums;
/// <summary>
/// The encounter images.
/// </summary>
public class GynEncounterImages
{
/// <summary>
/// Gets or sets the images.
/// </summary>
public List<GynSkinTypes> Images { get; set; }
/// <summary>
/// Gets or sets the json string.
/// </summary>
public string JsonString { get; set; }
/// <summary>
/// Gets or sets the encrypted appointment id.
/// </summary>
public string EncryptedAppointmentId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is admission.
/// </summary>
/// <value>
/// <c>true</c> if this instance is admission; otherwise, <c>false</c>.
/// </value>
public bool IsAdmission { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public int ModifiedBy { get; set; }
/// <summary>
/// Gets or sets the encounter id.
/// </summary>
public int? GynEncounterId { get; set; }
/// <summary>
/// Gets or sets the encounter type.
/// </summary>
public GynEncounterType Type { get; set; }
}
}
namespace Hims.Api.Models.GynEncounter
{
using System.Collections.Generic;
/// <summary>
/// The skin.
/// </summary>
public class GynSkin
{
/// <summary>
/// Gets or sets the encounter id.
/// </summary>
public int EncounterId { get; set; }
/// <summary>
/// Gets or sets the new images.
/// </summary>
public List<GynSkinTypes> NewImages { get; set; }
/// <summary>
/// Gets or sets the encrypted appointment id.
/// </summary>
public string EncryptedAppointmentId { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public int ModifiedBy { get; set; }
/// <summary>
/// Gets or sets the created by.
/// </summary>
public int CreatedBy { get; set; }
}
}
namespace Hims.Api.Models.GynEncounter
{
/// <summary>
/// The skin types.
/// </summary>
public class GynSkinTypes
{
/// <summary>
/// Gets or sets the type.
/// </summary>
public string Type { get; set; }
/// <summary>
/// Gets or sets the base 64 string.
/// </summary>
public string Base64String { get; set; }
/// <summary>
/// Gets or sets a value indicating whether edited.
/// </summary>
public bool Edited { get; set; }
}
}
\ No newline at end of file
namespace Hims.Api.Models.Homeopathy
{
/// <summary> The homeopathy delete request model.</summary>
public class HomeopathyDeleteRequestModel
{
/// <summary>Gets or sets the homeopathy id.</summary>
public int HomeopathyId { get; set; }
/// <summary>Gets or sets the account id.</summary>
public int AccountId { get; set; }
}
}
namespace Hims.Api.Models.Icons
{
/// <summary>
/// The icons request model.
/// </summary>
public class IconsRequestModel
{
/// <summary>
/// Gets or sets the page size.
/// </summary>
public int PageSize { get; set; }
/// <summary>
/// Gets or sets the page index.
/// </summary>
public int PageIndex { get; set; }
}
}
namespace Hims.Api.Models.InternalMedicine
{
using System.Collections.Generic;
using Hims.Shared.Library.Enums;
/// <summary>
/// The encounter images.
/// </summary>
public class EncounterImages
{
/// <summary>
/// Gets or sets the images.
/// </summary>
public List<SkinTypes> Images { get; set; }
/// <summary>
/// Gets or sets the json string.
/// </summary>
public string JsonString { get; set; }
/// <summary>
/// Gets or sets the encrypted appointment id.
/// </summary>
public string EncryptedAppointmentId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is admission.
/// </summary>
/// <value>
/// <c>true</c> if this instance is admission; otherwise, <c>false</c>.
/// </value>
public bool IsAdmission { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public int ModifiedBy { get; set; }
/// <summary>
/// Gets or sets the encounter id.
/// </summary>
public int? EncounterId { get; set; }
/// <summary>
/// Gets or sets the encounter type.
/// </summary>
public InternalMedicine Type { get; set; }
}
}
namespace Hims.Api.Models.InternalMedicine
{
using System.Collections.Generic;
/// <summary>
/// The skin.
/// </summary>
public class Skin
{
/// <summary>
/// Gets or sets the encounter id.
/// </summary>
public int EncounterId { get; set; }
/// <summary>
/// Gets or sets the new images.
/// </summary>
public List<SkinTypes> NewImages { get; set; }
/// <summary>
/// Gets or sets the encrypted appointment id.
/// </summary>
public string EncryptedAppointmentId { get; set; }
/// <summary>
/// Gets or sets the modified by.
/// </summary>
public int ModifiedBy { get; set; }
/// <summary>
/// Gets or sets the created by.
/// </summary>
public int CreatedBy { get; set; }
}
}
namespace Hims.Api.Models
{
/// <summary>
/// The JSON Request
/// </summary>
public class JsonRequest
{
/// <summary>
/// Gets or sets the JSON
/// </summary>
public string Json { get; set; } = string.Empty;
}
}
\ No newline at end of file
using Microsoft.AspNetCore.Mvc;
namespace Hims.Api.Models
{
/// <summary>
///
/// </summary>
public class LocationHeader
{
/// <summary>
/// Gets or sets the location identifier.
/// </summary>
/// <value>
/// The location identifier.
/// </value>
[FromHeader]
public string LocationId { get; set; }
/// <summary>
/// Gets or sets the location identifier.
/// </summary>
/// <value>
/// The created by identifier.
/// </value>
[FromHeader]
public string CreatedBy { get; set; }
}
}
using Hims.Shared.Library.Enums;
namespace Hims.Api.Models
{
/// <summary>
/// The JSON Request
/// </summary>
public class PaymentRequest
{
/// <summary>
/// Gets or sets the JSON
/// </summary>
public string Json { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the Type
/// </summary>
public PaymentModule Type { get; set; }
/// <summary>
/// Gets or sets the mode
/// </summary>
public string Mode { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the IsMobile
/// </summary>
public bool? IsMobile { get; set; }
/// <summary>
/// Gets or sets the IsMobile
/// </summary>
public bool? IsWebPatient { get; set; }
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment