Services Documentation - 123callumb/case-studies-basic-implementation GitHub Wiki

Services

Contents

GlobalActionFilter type

Namespace

Services.Filters

OnActionExecutionAsync(context,next) method

Summary

This method is called everytime a controller action is called. It ensures that the user in the current session has access to the action.

Returns
Parameters
Name Type Description
context Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext Current HttpContext
next Microsoft.AspNetCore.Mvc.Filters.ActionExecutionDelegate The intended action method.

HashHelper type

Namespace

Services.HashManagement.Implementation

CompareHashToValue(hash,value) method

Summary

Compare a hased value with a non hashed value, used for seeing if passwords are correct as it is not possible to has the value and see if it exists in the db. The password hash must first be brough back.

Returns

Will return true if the hash is equal to the value and false if not

Parameters
Name Type Description
hash System.String Hashed string
value System.String Value to compare

Hash(value) method

Summary

Hash a string with crytpo libs

Returns

hashed string

Parameters
Name Type Description
value System.String string value to hash

IAuthenticationManager type

Namespace

Services.AuthenticationManagement

AuthenticateExternalUser(sessionContext,email,password) method

Summary

For authenticating external users. (Part of the login process)

Returns

Void

Parameters
Name Type Description
sessionContext Microsoft.AspNetCore.Http.ISession
email System.String Users email address
password System.String Users password, compared with exisitng hash

AuthenticateInternalUser(sessionContext,email,password) method

Summary

For authenticating internal users. (Part of the login process)

Returns

Void

Parameters
Name Type Description
sessionContext Microsoft.AspNetCore.Http.ISession
email System.String Users email address
password System.String Users password, compared with exisitng hash

GetSessionUser(sessionContext) method

Summary

Get a users current session user external or internal, will return null if the user does not have a logged in session.

Returns

Abstract user, an abstract instance of both an external or internal user.

Parameters
Name Type Description
sessionContext Microsoft.AspNetCore.Http.ISession

IGenericQuerier type

Namespace

Services.GenericRepository

Summary

This is a generic query manager that subtracts the need for entity repositories.

LoadDbSet``1() method

Summary

Load db set from the db. Not suitable for loading large amounts of data as it keeps it's reference. Use with caution. Entity mappings should be done with Load``2 when loading large dataset that do not need to be edited.

Returns

Db set from the data base of type.

Parameters

This method has no parameters.

Generic Types
Name Description
TEntity Must be of type that belongs to the entities generated by the entity framework scaffold

LoadEntity``1(where) method

Summary

Directly loads an entity from the database and keeps its references. If an entity from this result is altered and save changes is called it will be modified on the database end too. Used for grabbing entities for deletion and updating.

Returns

Returns an entity with links to the dbset.

Parameters
Name Type Description
where System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}} That satisfy a specific predicate. If this is no required user LoadDbSet``1
Generic Types
Name Description
Entity Must be of type that belongs to the entities generated by the entity framework scaffold

Load``2(select,where) method

Summary

Load a dbset entity and map it into a dto with an optional where statement.

Returns

Returns an IQueryable of the entity which is executed once an async method is called on it. E.g. ToListAsync()

Parameters
Name Type Description
select System.Linq.Expressions.Expression{System.Func{``0,``1}} The map statement.
where System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}} Optional where statement.
Generic Types
Name Description
Entity Must be of type that belongs to the entities generated by the entity framework scaffold
EntityDTO Must be the mapping object that is no an object of the dbsets.

IGenericRepo type

Namespace

Services.GenericRepository

Summary

This is a generic repository that subtracts the need for entity repositories.

AddRange``1() method

Summary

Add a multiple rows to the database.

Returns

An integer for how many rows in the db have been affected.

Parameters

This method has no parameters.

Generic Types
Name Description
Entity Must be of type that belongs the entites generated by entity frameworks scaffold/

Add``1() method

Summary

Add a row to the database.

Returns

An integer for how many rows in the db have been affected.

Parameters

This method has no parameters.

Generic Types
Name Description
Entity Must be of type that belongs the entites generated by entity frameworks scaffold/

RemoveRange``1() method

Summary

Remove rows from the database.

Returns

An integer for how many rows in the db have been affected.

Parameters

This method has no parameters.

Generic Types
Name Description
Entity Must be of type that belongs the entites generated by entity frameworks scaffold/

Remove``1() method

Summary

Remove a row from the database.

Returns

An integer for how many rows in the db have been affected.

Parameters

This method has no parameters.

Generic Types
Name Description
Entity Must be of type that belongs the entites generated by entity frameworks scaffold/

SaveChanges() method

Summary

Used after editing dbset entities.

Returns

An integer for how many rows in the db have been affected.

Parameters

This method has no parameters.

IQuoteManager type

Namespace

Services.QuoteManagement

GetQuote(quoteID) method

Summary

A full quote with its summary and quote responses if it has any

Returns

Returns a quote

Parameters
Name Type Description
quoteID System.Int32 Unique identifier for the quote

GetQuotes() method

Summary

Load all quotes that are currently on the system

Returns

A List of quotes

Parameters

This method has no parameters.

GetVendorQuotes(vendorID) method

Summary

Get a list of all quotes associated with a specific vendor

Returns

Returns a list of quote overviews, the quote overview object is a small summaty of the quote without its quote responses attatched.

Parameters
Name Type Description
vendorID System.Int32 Unique vendor id

RequestQuote(item,quantity) method

Summary

Used to request a quote from a vendor

Returns

Returns a bool, true if the request is created.

Parameters
Name Type Description
item Services.Models.DTOs.VendorItemDTO The item in question
quantity System.Int32 The amount of the item in question requested

IQuoteResponseManager type

Namespace

Services.QuoteResponseManagement

Create(response) method

Summary

Create a quote response

Returns

Returns a boolean, will be true of the response is successfully created.

Parameters
Name Type Description
response Services.EntityFramework.DbEntities.QuoteResponse Takes in a quoete response object which asks for a quote id associated with the response, a response text and a price.

IUserManager type

Namespace

Services.UserManagement

GetExternalUser(userID) method

Summary

Load External user, this user is a user from outside of the abcs internal system

Returns

Returns the external user object

Parameters
Name Type Description
userID System.Int32 Unique id for that user

IVendorItemManager type

Namespace

Services.VendorItemManagement

LoadVendorItem(ID) method

Summary

Get a vendor item associated with a specific id

Returns

Returns a vendor item specific to the give id

Parameters
Name Type Description
ID System.Int32 Requires a vendor items unique id.

LoadVendorItems() method

Summary

Load all vendor items that are in the abc system

Returns

A list of vendro items containiing thier details such as name and description.

Parameters

This method has no parameters.

SearchVendorItems(searchString) method

Summary

Search vendor item by seeing ifthe given string is contained within the items namn

Returns

Can return a list of 1 - x or an empty list if nothing is found.

Parameters
Name Type Description
searchString System.String Search string

IVendorManager type

Namespace

Services.VendorManagement

GetVendor(vendorId) method

Summary

Loading vendor entity, for vendors associateed with abc

Returns

Returns a vendor dto

Parameters
Name Type Description
vendorId System.Int32 Use a vendors unique id to get.

SessionHelper type

Namespace

Services.SessionManagement.Helpers

GetUserSession(session) method

Summary

Used to see if their is a current user session stored in memory

Returns

Returns an authenticated session if a user has an exisitng session or will return null if there is no user session

Parameters
Name Type Description
session Microsoft.AspNetCore.Http.ISession Controller session contexxt

Get``1(session,key) method

Summary

Helper for getting custom session objects

Returns
Parameters
Name Type Description
session Microsoft.AspNetCore.Http.ISession
key System.String
Generic Types
Name Description
T

HasUserSession(session) method

Summary

Bool checker to see of the current user has a logged in session for either an external or internal user.

Returns

Returns true if there is a user session and false if none was found

Parameters
Name Type Description
session Microsoft.AspNetCore.Http.ISession Session context from a controller

Set``1(session,key,value) method

Summary

Helper for setting custom objects in the session

Parameters
Name Type Description
session Microsoft.AspNetCore.Http.ISession
key System.String
value ``0
Generic Types
Name Description
T