public bool GetPasswordReset(string password, Admin adminModel) { using (AdminContext db = new AdminContext()) { try { if (adminModel != null) { adminModel.Password = password; adminModel.ModifiedDate = DateTime.Now; db.Entry(adminModel).State = EntityState.Modified; db.SaveChanges(); return(true); } else { return(false); } } catch (Exception) { return(false); } } }
/// <summary> /// Initializes a new instance of the <see cref="AgentCategoryRepository" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> public AgentCategoryRepository( AdminContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
// rsPolicies public static IEnumerable <Dictionary <string, object> > GetSchoolPolicies(int schoolId) { List <Dictionary <string, object> > data; SqlParameter[] parametes = new[] { new SqlParameter("SchoolId", schoolId) }; using (AdminContext ctx = new AdminContext()) { data = SqlHelper.ExecProcedure(ctx, "spGetSchoolPolicies", parametes); } var rsPolicies = data.AsEnumerable(); var FilteredPolicies = rsPolicies .Where(x => x["term_date"] != null && Convert.ToDateTime(x["term_date"]) >= DateTime.Now); var OrderedPolicies = FilteredPolicies .OrderByDescending(x => x["eff_date"]) .ThenBy(x => x["policy_number"]) .ThenBy(x => x["description"]); return(OrderedPolicies); //return data.AsEnumerable(); }
public bool EditFacultyNominationStatus(Faculty faculty, string status, int?batchId, Batch batch) { AdminContext admindb = new AdminContext(); if (faculty != null && batch != null) { faculty.NominationStatus = status; faculty.BatchId = batchId; if (status == "Accepted") { batch.AssignFacultyStatus = "yes"; } else { batch.AssignFacultyStatus = "no"; } admindb.Entry(batch).State = EntityState.Modified; admindb.SaveChanges(); db.Entry(faculty).State = EntityState.Modified; db.SaveChanges(); return(true); } else { return(false); } }
private string LoadGlobalSettingsVersion(AdminContext db) { var dbSettings = db.GlobalSettings.FirstOrDefault(); var version = dbSettings?.SettingsVersion ?? Guid.Empty; return(version.ToString()); }
public SiteLibraryBrowser(IFolderManager <FileDocument> folderManager, IContextAccessor <AdminContext> adminContextAccessor) { _folderManager = folderManager; _adminContext = adminContextAccessor.GetContext(); ownerId = _adminContext?.SiteId; }
public AdminService(AdminContext adminContext) { if (this._adminContext == null) { this._adminContext = adminContext; } }
public AdminDetailController(AdminDetailContext context, ActionResponse actionContext, AdminContext userContext, LogContext logContext) { _context = context; _actionContext = actionContext; _userContext = userContext; _logContext = logContext; }
public TypeStatusUpdate GetStatusPacote(Package pacote, AppConfigIts app) { try { using (var ctx = new AdminContext(app.ConnectionString)) { try { //busca o pacote no banco var pkgCurrent = ctx.UpdateInfoDao.Where(u => u.NumeroPacote == pacote.NumeroPacote) .First(); return(pkgCurrent.Status); } catch { //whatever return(TypeStatusUpdate.NaoAplicado); } } } catch (Exception) { //fodase, retorna nao aplicado e tenta de novo return(TypeStatusUpdate.Erro); } }
public ActionResult Index() { using (AdminContext db = new AdminContext()) { return(View(db.admins.ToList())); } }
/// <summary> /// Initializes a new instance of the <see cref="SchedulingCodeRepository" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> public SchedulingCodeRepository( AdminContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
public ServiceFixture() { var admin = new AdminContext(new DbContextOptions <AdminContext>()); ILogger <DeptManager> logger = new LoggerTest(); Sut = new DeptManager(admin, logger); }
/// <summary> /// Initializes a new instance of the <see cref="UserLanguageRepository" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> public UserLanguageRepository( AdminContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AdminContext adminContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); DbInitializer.Seed(adminContext); }
public TypeStatusUpdate GetStatusPacote(Package pacote, string connectionString = null) { try { var ctx = new AdminContext(); if (connectionString != null) { ctx.Dispose(); ctx = new AdminContext(connectionString); } using (ctx) { try { //busca o pacote no banco var pkgCurrent = ctx.UpdateInfoDao.Where(u => u.NumeroPacote == pacote.NumeroPacote) .First(); return(pkgCurrent.Status); } catch { //whatever return(TypeStatusUpdate.NaoAplicado); } } } catch (Exception) { //fodase, retorna nao aplicado e tenta de novo return(TypeStatusUpdate.NaoAplicado); } }
public CulturesController(ILogger <CulturesController> logger, IStringLocalizer <CulturesController> localizer, IServiceProvider serviceProvider) : base(logger, localizer, serviceProvider) { _db = serviceProvider.GetRequiredService <AdminContext>(); _logger = logger; _localizer = localizer; }
private void updateItens(AdminContext ctx, Package package, Package novo) { //atualizando os itens atuais for (int i = 0; i < package.Anexos.Count; i++) { var item = package.Anexos.ToList()[i]; //verifica se o item atual ja esta na nova lista var itemAtualizado = novo.Anexos.ToList().Find(x => x.IdAnexo == item.IdAnexo); //se ele existe ou vou atualiza-lo if (itemAtualizado != null) { var a = ctx.AnexoPackageDao.Find(itemAtualizado.IdAnexo); //atualiza o item item.Update(itemAtualizado); ctx.AnexoPackageDao.Update(a); } //ele nao existe else { var a = ctx.AnexoPackageDao.Find(item.IdAnexo); // então ele nao faz parte da lista de arquivos //marque o item para ser removido ctx.AnexoPackageDao.Delete(a); } } }
private static async Task <IEnumerable <Word.Types.AudioCard> > GetAudioCards( AdminContext dbContext, IEnumerable <Word.Types.Pronunciation> prons, int?maybeWordId) { var output = new List <Word.Types.AudioCard>(); output.AddRange(prons.Select(p => new Word.Types.AudioCard() { Pronunciation = p.Pronunciation_, HintPrimary = p.DisplayName, Audio = p.Audio })); if (!maybeWordId.HasValue) { return(output.ToImmutableArray()); } var audioClips = await Queries.QueryAudioClipsByWordId(dbContext, maybeWordId.Value).ToListAsync(); output.AddRange(audioClips.Select(Renderers.ToAudioCard)); return(output.ToImmutableArray()); }
/// <summary> /// Initializes a new instance of the <see cref="SchedulingCodeRepository" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> public CssVariableRepository( AdminContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
private void bAuthorize_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.AppStarting; AdminContext adminContext = new AdminContext(); logger.Debug("Поиск введенных логина и пароля в БД"); var LogPerson = adminContext.Logins.Where(l => l.login.Equals(tbLogin.Text)); if (!LogPerson.Any()) { MessageBox.Show("Не найдено пользователя с таким логином"); logger.Info($"В БД не найдено пользователя с логином \"{tbLogin.Text}\""); } else { if (LogPerson.SingleOrDefault().password.Equals(pbPassword.Password)) { var user = LogPerson.SingleOrDefault().person; App.user = user; App.priveleges = user.post.privelege; Mouse.OverrideCursor = Cursors.Arrow; logger.Info($"Пользователь под Id №{user.PersonId} в должности {user.post.Name} вошел в систему"); this.Close(); } else { Mouse.OverrideCursor = Cursors.Arrow; logger.Info("Введен неверный пароль"); MessageBox.Show("Неверный пароль"); } } }
//Dletes the current DB. public void DeleteDB() { using (var db = new AdminContext()) { db.Database.Delete(); } }
public TranslationsController(AdminContext db, ISqlStringLocalizerFactory localizerFactory, ILogger <TranslationsController> logger, IStringLocalizer <TranslationsController> localizer, IServiceProvider serviceProvider) : base(logger, localizer, serviceProvider) { _db = db; _localizerFactory = localizerFactory; _logger = logger; }
public AuthRepository( AdminContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
public AdminController(AdminContext context, ActionResponse actionContext, LogContext logContext, BalanceContext balanceContext) { _context = context; _actionContext = actionContext; _logContext = logContext; _balanceContext = balanceContext; }
public ActionResult Validate(FormCollection formCollection) { AdminContext adminContext = new AdminContext(); List <Admins> admins = adminContext.Admins.ToList(); { var _admin = admins.Where(s => s.Username == formCollection["Username"]); if (_admin.Any()) { if (_admin.Where(s => s.Password == formCollection["Password"]).Any()) { Session["Email"] = formCollection["Username"]; return(RedirectToAction("Index", "RotationList")); } else { TempData["LoginMessage"] = "Invalid Password!"; return(RedirectToAction("AdminLogin", "Admin")); } } else { TempData["LoginMessage"] = "Invalid Email!"; return(RedirectToAction("AdminLogin", "Admin")); } } }
/// <summary> /// Initializes a new instance of the <see cref="RepositoryWrapper" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> /// <param name="">The .</param> public RepositoryWrapper( AdminContext repositoryContext, IMapper mapper) { _repositoryContext = repositoryContext; _mapper = mapper; }
public UrlVO FindUrlByUrl(AdminContext ctx, string url) { UrlVO model = new UrlVO(); try { var query = (from u in ctx.Url where u.Url == url select new { u.Id, u.GUID, u.CreationDate, u.ExpireDate }).Single(); model.Id = FillItemForDatabase.FillItem(query.Id); model.Url = url; model.GUID = FillItemForDatabase.FillItem(query.GUID); model.CreationDate = FillItemForDatabase.FillItem(query.CreationDate); model.ExpireDate = FillItemForDatabase.FillItem(query.ExpireDate); } catch { throw; } return(model); }
/// <summary> /// Initializes a new instance of the <see cref="SchedulingCodeRepository" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> public LanguageTranslationRepository( AdminContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
/// <summary> /// Initializes a new instance of the <see cref="UserPermissionRepository" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> public UserPermissionRepository( AdminContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
public bool AddInformationUpdate(Package pacote, UpdateInfo updateInfo, AppConfigIts app) { try { using (var ctx = new AdminContext(app.ConnectionString)) { try { //busca o pacote var current = ctx.UpdateInfoDao.Where(u => u.NumeroPacote == pacote.NumeroPacote && u.Status == TypeStatusUpdate.Erro) .First(); current.Update(updateInfo); return(ctx.UpdateInfoDao.Update(current)); } catch (Exception) { return(ctx.UpdateInfoDao.Save(updateInfo)); } } } catch (Exception ex) { XMessageIts.ExceptionMessage(ex, "Falha ao inserir log de aplicação de pacote", "Aplicação de Pacote"); return(false); } }
public AdminController(ComponentContext ctx, AdminContext adm) { db = ctx; admin = adm; if(!User?.HasClaim(p=>p.Type=="LpaAccess"&&p.Value=="Admin") ?? true) { Reject(); } }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); var adminContext = new AdminContext { CurrentUser = DataContext.AdminUsers.SingleOrDefault(i => i.UserName == HttpContext.User.Identity.Name) }; if (CurrentSiteId != 0) { adminContext.CurrentSite = DataContext.Sites.FirstOrDefault(i => i.Id == CurrentSiteId); } AdminContext.Current = adminContext; InitAdminPanelLanguage(); }