private bool IsValidRequest() { Thread.Sleep(2000); if (this.Context == null) { this.Clients.Caller.getNotification(I18N.AccessIsDenied); return(false); } string tenant = AppUsers.GetTenant(); long loginId = HubAuthorizationManger.GetLoginIdAsync(tenant, this.Context).GetAwaiter().GetResult(); var meta = AppUsers.GetCurrent(tenant, loginId); if (loginId <= 0) { this.Clients.Caller.getNotification(I18N.AccessIsDenied); return(false); } if (!meta.IsAdministrator) { return(false); } return(true); }
public static string GetDashboardPath() { string tenant = AppUsers.GetTenant(); string path = HostingEnvironment.MapPath(Format(CultureInfo.InvariantCulture, Path, tenant)); return(path != null && !System.IO.Directory.Exists(path) ? Empty : path); }
public static string GetGoogleMapsJavascriptApi() { string tenant = AppUsers.GetTenant(); var google = Google.ConfigurationManager.Get(tenant); return(google.MapsJavascriptApiKey); }
public static IEnumerable <Content> GetContents() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <Content>(sql => sql.Where(c => c.IsHomepage))); } }
public static IEnumerable <Menu> GetMenus() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <Menu>(sql => sql).OrderBy(x => x.Sort).ThenBy(x => x.MenuId)); } }
public static DTO.Reset GetIfActive(string token) { const string sql = "SELECT * FROM account.reset_requests WHERE request_id=@0::uuid AND expires_on >= NOW() AND NOT confirmed;"; return(Factory.Get <DTO.Reset>(AppUsers.GetTenant(), sql, token).FirstOrDefault()); }
public static IEnumerable <Role> GetRoles() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <Role>(sql => sql).OrderByDescending(x => x.RoleId)); } }
public static DTO.Configuration GetDefaultConfiguration() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <DTO.Configuration>(sql => sql.Where(c => c.IsDefault)).FirstOrDefault()); } }
public static IEnumerable <PublishedContentView> GetAllPublishedContents() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <PublishedContentView>(sql => sql)); } }
public static IEnumerable <PublishedContentView> GetBlogContents(int limit, int offset) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <PublishedContentView>(sql => sql.Where(x => x.IsBlog)).Skip(offset).Take(limit)); } }
public static ConfigurationProfile GetActiveProfile() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <ConfigurationProfile>(sql => sql.Where(u => u.IsActive)).FirstOrDefault()); } }
public ActionResult Get(string resource = "") { if (string.IsNullOrWhiteSpace(resource)) { return(this.HttpNotFound()); } string directory = "~/Tenants/{0}/Areas/Frapid.Dashboard/Resources/"; directory = string.Format(CultureInfo.InvariantCulture, directory, AppUsers.GetTenant()); directory = HostingEnvironment.MapPath(directory); if (directory == null) { return(this.HttpNotFound()); } string path = Path.Combine(directory, resource); if (!System.IO.File.Exists(path)) { return(this.HttpNotFound()); } string mimeType = MimeMapping.GetMimeMapping(path); return(this.File(path, mimeType)); }
public static int CountBlogContents() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <PublishedContentView>(sql => sql.Where(x => x.IsBlog)).Count); } }
public static void SavePolicy(int officeId, int userId, List <AccessPolicyInfo> policies) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { db.BeginTransaction(); var sql = new Sql(); sql.Append("DELETE FROM auth.entity_access_policy"); sql.Append("WHERE office_id = @0", officeId); sql.Append("AND user_id = @0", userId); db.Execute(sql); foreach (var policy in policies) { dynamic poco = new ExpandoObject(); poco.entity_name = policy.EntityName; poco.office_id = officeId; poco.user_id = userId; poco.access_type_id = policy.AccessTypeId; poco.allow_access = policy.AllowAccess; db.Insert("auth.entity_access_policy", "entity_access_policy_id", true, poco); } db.CompleteTransaction(); } }
public static IEnumerable <MenuItemView> GetMenuItems(string menuName) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <MenuItemView>(sql => sql.Where(c => c.MenuName == menuName)).OrderBy(c => c.Sort)); } }
public static Contact GetContact(int contactId) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <Contact>(sql => sql.Where(c => c.ContactId.Equals(contactId))).FirstOrDefault()); } }
public static string GetOverridePath() { string tenant = AppUsers.GetTenant(); string path = HostingEnvironment.MapPath(string.Format(CultureInfo.InvariantCulture, Path, tenant)); return(path != null && !Directory.Exists(path) ? string.Empty : path); }
public static IEnumerable <User> GetUsers() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <User>(sql => sql.Where(x => x.Status))); } }
public static string GetThemeDirectory() { string tenant = AppUsers.GetTenant(); string path = Path + "Themes"; return(Format(CultureInfo.InvariantCulture, path, tenant)); }
public static User Get(string email) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <User>(sql => sql.Where(u => u.Email == email)).FirstOrDefault()); } }
public static LoginResult SignIn(string email, int officeId, string name, string token, string browser, string ipAddress, string culture) { string sql = FrapidDbServer.GetProcedureCommand("account.google_sign_in", new[] { "@0", "@1", "@2", "@3", "@4", "@5", "@6" }); return(Factory.Get <LoginResult>(AppUsers.GetTenant(), sql, email, officeId, name, token, browser, ipAddress, culture.Or("en-US")).FirstOrDefault()); }
public static DTO.Reset Request(ResetInfo model) { string sql = FrapidDbServer.GetProcedureCommand("account.reset_account", new[] { "@0", "@1", "@2" }); return (Factory.Get <DTO.Reset>(AppUsers.GetTenant(), sql, model.Email, model.Browser, model.IpAddress) .FirstOrDefault()); }
public static IEnumerable <MenuAccessPolicy> GetPolicy(int officeId, int userId) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <MenuAccessPolicy> (sql => sql.Where(x => x.OfficeId.Equals(officeId) && x.UserId.Equals(userId)))); } }
public static string GetCurrentThemePath() { string tenant = AppUsers.GetTenant(); string path = Path + "Themes/{1}/"; string theme = GetDefaultTheme(); return(Format(CultureInfo.InvariantCulture, path, tenant, theme)); }
public List <Filter> GetFilters(string database, string filterName) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <Filter>(sql => sql.Where(u => u.ObjectName.Equals(this.FullyQualifiedObjectName) && u.FilterName.ToUpperInvariant().Equals(filterName.ToUpperInvariant())))); } }
public async Task <ActionResult> SendEmailAsync(ContactForm model) { model.Subject = "Contact Form : " + model.Subject; string tenant = AppUsers.GetTenant(); await new ContactUsEmail().SendAsync(tenant, model); Thread.Sleep(1000); return(this.Json("OK")); }
public static object Register(DTO.Registration registration) { registration.RegistrationId = Guid.NewGuid(); registration.RegisteredOn = DateTimeOffset.UtcNow; Factory.Insert(AppUsers.GetTenant(), registration, "account.registrations", "registration_id", false); return(registration.RegistrationId); }
public static PublishedContentView GetDefault() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return (db.FetchBy <PublishedContentView>(sql => sql.Where(c => c.IsHomepage).Limit(1)) .FirstOrDefault()); } }
public static IEnumerable <Contact> GetContacts() { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <Contact>(sql => sql.Where(c => c.Status)) .OrderBy(c => c.Sort) .ThenBy(c => c.ContactId)); } }
public static int[] GetGroupPolicy(int officeId, int roleId) { using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase()) { return(db.FetchBy <GroupMenuAccessPolicy> (sql => sql.Where(x => x.OfficeId.Equals(officeId) && x.RoleId.Equals(roleId))) .Select(x => x.MenuId) .ToArray()); } }