// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, HelpdeskDbContext ctx) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var swaggerOptions = new SwaggerOptions(); Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description); }); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); ctx.Database.Migrate(); }
public override bool ValidateUser(string username, string password) { using (HelpdeskDbContext context = new HelpdeskDbContext()) { var user = context.Users.Where(x => x.UserName.Equals(username) && x.Password.Equals(password)).FirstOrDefault(); if (user != null) { return(true); } } return(false); }
public override string[] GetRolesForUser(string username) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { return(null); } var cacheKey = string.Format("{0}_role", username); if (HttpRuntime.Cache[cacheKey] != null) { return((string[])HttpRuntime.Cache[cacheKey]); } string[] roles = { }; using (HelpdeskDbContext context = new HelpdeskDbContext()) { roles = context.Users.Include("Roles").Where(u => u.UserName.Equals(username)).SingleOrDefault().Roles.Select(s => s.Name).ToArray <string>(); if (roles.Count() > 0) { HttpRuntime.Cache.Insert(cacheKey, roles, null, DateTime.Now.AddMinutes(_cacheTimeOutInMinute), Cache.NoSlidingExpiration); } } return(roles); }
public HomeController(HelpdeskDbContext _context) { context = _context; }
public ComponentsController(HelpdeskDbContext _context) { context = _context; }
public string Get(string reqType, string status) { HelpdeskDbContext dbContextHelpdesk = new HelpdeskDbContext(connString); AdmissionDbContext dbAdmission = new AdmissionDbContext(connString); DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>(); try { //gets the EmployeeInfo from Employee table if (reqType == "getHelpdesk") { //.ToList()is done two times,since we can't use requestDate.Date inside IQueryable List <EmployeeInfoModel> empsInfoList = dbContextHelpdesk.GetEmployeeInfo(); //where d.EmployeeId == employeeId responseData.Status = "OK"; //loads EmployeeInfo with requested status responseData.Results = empsInfoList; } //gets the BedInformation from Bed,Bedtype and Ward tables if (reqType == "getBedinfo") { //.ToList()is done two times,since we can't use requestDate.Date inside IQueryable DynamicReport bedsInfoList = dbContextHelpdesk.GetBedInformation(); responseData.Status = "OK"; responseData.Results = bedsInfoList; } //gets the BedInformation , Patient Information and Ward Name if (reqType == "getBedPatientInfo") { var bedpatientinfo = dbAdmission.Beds.ToList().GroupJoin(dbAdmission.PatientBedInfos.ToList().Where(a => a.EndedOn == null), a => a.BedId, b => b.BedId, (a, b) => new BedPatientViewModel { BedId = a.BedId, WardId = a.WardId, BedCode = a.BedCode, PatientId = b.Select(s => s.PatientId).FirstOrDefault(), PatientBedInfoId = b.Select(s => s.PatientBedInfoId).FirstOrDefault(), StartedOn = b.Select(s => s.StartedOn).FirstOrDefault(), EndedOn = b.Select(s => s.EndedOn).FirstOrDefault(), BedNumber = a.BedNumber, IsOccupied = a.IsOccupied }).GroupJoin(dbAdmission.Patients.ToList(), a => a.PatientId, b => b.PatientId, (a, b) => new BedPatientViewModel { BedId = a.BedId, WardId = a.WardId, BedCode = a.BedCode, PatientId = b.Select(s => s.PatientId).FirstOrDefault(), PatientBedInfoId = a.PatientBedInfoId, StartedOn = a.StartedOn, EndedOn = a.EndedOn, BedNumber = a.BedNumber, IsOccupied = a.IsOccupied, PatientName = b.Select(s => s.FirstName).FirstOrDefault() + " " + b.Select(s => s.MiddleName).FirstOrDefault() + " " + b.Select(s => s.LastName).FirstOrDefault(), PatientCode = b.Select(s => s.PatientCode).FirstOrDefault(), Address = b.Select(s => s.Address).FirstOrDefault() }).GroupJoin(dbAdmission.Wards.ToList(), a => a.WardId, b => b.WardId, (a, b) => new BedPatientViewModel { BedId = a.BedId, WardId = b.Select(s => s.WardId).FirstOrDefault(), WardName = b.Select(s => s.WardName).FirstOrDefault(), BedCode = a.BedCode, PatientId = a.PatientId, PatientBedInfoId = a.PatientBedInfoId, StartedOn = a.StartedOn, EndedOn = a.EndedOn, BedNumber = a.BedNumber, IsOccupied = a.IsOccupied, PatientName = a.PatientName, PatientCode = a.PatientCode, Address = a.Address }).GroupJoin(dbAdmission.Admissions.ToList(), a => a.PatientId, b => b.PatientId, (a, b) => new BedPatientViewModel { BedId = a.BedId, WardId = a.WardId, WardName = a.WardName, BedCode = a.BedCode, PatientId = a.PatientId, PatientBedInfoId = a.PatientBedInfoId, StartedOn = a.StartedOn, EndedOn = a.EndedOn, BedNumber = a.BedNumber, IsOccupied = a.IsOccupied, PatientName = a.PatientName, PatientCode = a.PatientCode, Address = a.Address, PatientVisitId = b.Select(s => s.PatientVisitId).FirstOrDefault(), PatientAdmissionId = b.Select(s => s.PatientAdmissionId).FirstOrDefault(), DischargedDate = b.Select(s => s.DischargeDate).FirstOrDefault(), AdmittedDate = b.Select(s => s.AdmissionDate).FirstOrDefault() }); responseData.Status = "OK"; responseData.Results = bedpatientinfo; } //gets the WardInformation from WardBedType and Ward tables if (reqType == "getWardinfo") { //data from GetWardInformation Method from Dbcontext List <WardInformationModel> wardsInfoList = dbContextHelpdesk.GetWardInformation(); responseData.Status = "OK"; responseData.Results = wardsInfoList; } else if (reqType == "getBedFeature") { DanpheHTTPResponse <DataTable> data = new DanpheHTTPResponse <DataTable>(); try { HelpdeskDbContext helpdeskDbContext = new HelpdeskDbContext(connString); DataTable dtResult = helpdeskDbContext.BedFeatureReprot(); data.Status = "OK"; data.Results = dtResult; } catch (Exception ex) { //Insert exception details into database table. data.Status = "Failed"; data.ErrorMessage = ex.Message; } return(DanpheJSONConvert.SerializeObject(data)); } } catch (Exception ex) { responseData.Status = "Failed"; responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString(); } return(DanpheJSONConvert.SerializeObject(responseData, true)); }
public MyAccountController(HelpdeskDbContext _context) { context = _context; }