// { //get //{ // return (IConfiguration)context.HttpContext.RequestServices.GetService(typeof(IConfiguration)); //} // } public override void OnActionExecuting(ActionExecutingContext context) { SystemSettingsRepository systemsettingsrepository; var user = context.HttpContext.User; _configuration = (IConfiguration)context.HttpContext.RequestServices.GetService(typeof(IConfiguration)); var token = context.HttpContext.Request.Query["Token"]; dbConext = new DbConext(); if (token == "") { // throw new UnauthorizedAccessException("Invalid Token"); context.Result = new UnauthorizedResult(); } systemsettingsrepository = dbConext.SystemSettings.FirstOrDefault(); if (systemsettingsrepository == null) { //throw new UnauthorizedAccessException("Invalid Token"); context.Result = new UnauthorizedResult(); } if (token != systemsettingsrepository.Token) { // throw new UnauthorizedAccessException("Invalid Token"); context.Result = new UnauthorizedResult(); // return; } }
public virtual DTO Get(int id) { T entity; try { using (var db = new DbConext()) { entity = db.Set <T>().Find(id); } } catch (Exception e) { ThrowError(e); // handles logging, verbosity per environment, etc throw new HttpResponseException(HttpStatusCode.InternalServerError); } if (entity == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } DTO dto = Mapper.Map <DTO>(entity); // project entity to DTO using AutoMapper (or do it manually) return(dto); }
public VaccinationTypesRepositoriesController(DbConext context) { _context = context; }