private void CreatePresent() { var presentId = System.Guid.NewGuid().ToString(); var userId = User.Identity.GetUserId(); var list = Request.Form.AllKeys; var photos = DatabaseContextManager.GetPhotosUserNotPresentation(User.Identity.GetUserId()); var present = new PresentationExModel(); present.PresentationId = presentId; present.UserId = userId; int index = 0; foreach (var a in list) { foreach (var b in photos) { if (Request.Form[a].Equals(b.PhotoId)) { if (index == 0) { present.PathBeginPhoto = DatabaseContextManager.GetPathPhoto(b.PhotoId); } b.PresentationId = presentId; b.PositionNumber = index; index++; } } } present.Photos = photos; DatabaseContextManager.AddPresentation(present); }
public void RegisterDependencies(Container container) { //http context container.RegisterInstance <HttpContextBase>(new HttpContextWrapper(HttpContext.Current) as HttpContextBase, new SingletonReuse()); //cache provider container.Register <ICacheProvider, HttpCacheProvider>(reuse: Reuse.Singleton); // settings register for access across app container.Register <IDatabaseSettings>(made: Made.Of(() => new DatabaseSettings()), reuse: Reuse.Singleton); //data provider : TODO: Use settings to determine the support for other providers container.Register <IDatabaseProvider>(made: Made.Of(() => new SqlServerDatabaseProvider()), reuse: Reuse.Singleton); //database context container.Register <IDatabaseContext>(made: Made.Of(() => DatabaseContextManager.GetDatabaseContext()), reuse: Reuse.Singleton); //and respositories container.Register(typeof(IDataRepository <>), typeof(EntityRepository <>)); var asm = AssemblyLoader.LoadBinDirectoryAssemblies(); //services //to register services, we need to get all types from services assembly and register each of them; var serviceAssembly = asm.First(x => x.FullName.Contains("mobSocial.Services")); var serviceTypes = serviceAssembly.GetTypes(). Where(type => type.IsPublic && // get public types !type.IsAbstract && // which are not interfaces nor abstract type.GetInterfaces().Length != 0); // which implementing some interface(s) container.RegisterMany(serviceTypes, reuse: Reuse.Singleton, ifAlreadyRegistered: IfAlreadyRegistered.Replace); //we need a trasient reporter service rather than singleton container.Register <IVerboseReporterService, VerboseReporterService>(reuse: Reuse.InResolutionScope, ifAlreadyRegistered: IfAlreadyRegistered.Replace); //settings var allSettingTypes = TypeFinder.ClassesOfType <ISettingGroup>(); foreach (var settingType in allSettingTypes) { var type = settingType; container.RegisterDelegate(type, resolver => { var instance = (ISettingGroup)Activator.CreateInstance(type); resolver.Resolve <ISettingService>().LoadSettings(instance); return(instance); }, reuse: Reuse.Singleton); } //and ofcourse the page generator container.Register <IPageGenerator, PageGenerator>(reuse: Reuse.Singleton); //event publishers and consumers container.Register <IEventPublisherService, EventPublisherService>(reuse: Reuse.Singleton); //all consumers which are not interfaces container.RegisterMany(new[] { typeof(IEventConsumer <>) }, serviceTypeCondition: type => !type.IsInterface); }
public OAuthDbContext Create() { try { return(DatabaseContextManager.GetDatabaseContext <OAuthDbContext>()); } catch { return(DatabaseContextManager.GetDatabaseContext <OAuthDbContext>(DatabaseManager.FallbackConnectionStringName)); } }
private string UploadFileEx(String url) { String guid = System.Guid.NewGuid().ToString(); DatabaseContextManager.AddPhoto(new PhotoModel() { PhotoId = guid, UserId = User.Identity.GetUserId(), PhotoPath = cloudinaryManager.UploadImage(url, guid), PhotoName = "", PhotoDescription = "" }); return(guid); }
private void CreateManagerModel(out ManagerModel model, out List <PresentationExModel> presentation) { model = new ManagerModel(); model.UserFloatPhotos = DatabaseContextManager.GetPhotosUserNotPresentation(User.Identity.GetUserId()); presentation = DatabaseContextManager.GetAllPresentation(); model.PathBeginPhoto = new List <string>(); foreach (var a in presentation) { model.PathBeginPhoto.Add(a.PathBeginPhoto); } model.Present = new List <PhotoModel>(); }
public ActionResult UploadEx(String url) { String guid = UploadFileEx(url); var photos = DatabaseContextManager.GetPhotosUserNotPresentation(User.Identity.GetUserId()); foreach (var a in photos) { if (a.PhotoId.Equals(guid)) { return(Json(JsonConvert.SerializeObject(a), JsonRequestBehavior.AllowGet)); } } return(View("Manager")); }
public void RegisterDependencies(Container container) { container.Register <IClientService, ClientService>(); container.Register <IAppTokenService, AppTokenService>(); container.RegisterDelegate <IDataRepository <OAuthClient> >( resolver => new EntityRepository <OAuthClient>(DatabaseContextManager.GetDatabaseContext <OAuthDbContext>()), ifAlreadyRegistered: IfAlreadyRegistered.Replace); container.RegisterDelegate <IDataRepository <AppToken> >( resolver => new EntityRepository <AppToken>(DatabaseContextManager.GetDatabaseContext <OAuthDbContext>()), ifAlreadyRegistered: IfAlreadyRegistered.Replace); //override authentication service container.Register <IAuthenticationService, OAuthAuthenticationService>( ifAlreadyRegistered: IfAlreadyRegistered.Replace); }
private void UploadFile() { foreach (string upload in Request.Files) { if (Request.Files[upload] == null) { continue; } String guid = System.Guid.NewGuid().ToString(); DatabaseContextManager.AddPhoto(new PhotoModel() { PhotoId = guid, UserId = User.Identity.GetUserId(), PhotoPath = cloudinaryManager.UploadImage(Request.Files[upload].FileName, Request.Files[upload].InputStream, guid), PhotoName = "", PhotoDescription = "" }); } }
public void RegisterDependencies(IContainer container) { container.Register <IClientService, ClientService>(); container.Register <IAppTokenService, AppTokenService>(); container.Register <IDatabaseContext>(made: Made.Of(() => DatabaseContextManager.GetDatabaseContext <OAuthDbContext>()), serviceKey: ContextServiceKey, reuse: Reuse.InWebRequest); container.RegisterDelegate <IDataRepository <OAuthClient> >( resolver => new EntityRepository <OAuthClient>(ContextServiceKey), ifAlreadyRegistered: IfAlreadyRegistered.Replace, reuse: Reuse.Singleton); container.RegisterDelegate <IDataRepository <AppToken> >( resolver => new EntityRepository <AppToken>(ContextServiceKey), ifAlreadyRegistered: IfAlreadyRegistered.Replace, reuse: Reuse.Singleton); //override authentication service container.Register <IAuthenticationService, OAuthAuthenticationService>( ifAlreadyRegistered: IfAlreadyRegistered.Replace, reuse: Reuse.InWebRequest); }
public OAuthDbContext Create() { return(DatabaseContextManager.GetDatabaseContext <OAuthDbContext>()); }
public void RegisterDependencies(IContainer container) { //http context container.RegisterInstance <HttpContextBase>(new HttpContextWrapper(HttpContext.Current) as HttpContextBase, new SingletonReuse()); //cache provider container.Register <ICacheProvider, HttpCacheProvider>(reuse: Reuse.Singleton); // settings register for access across app container.Register <IDatabaseSettings>(made: Made.Of(() => new DatabaseSettings()), reuse: Reuse.Singleton); //data provider : TODO: Use settings to determine the support for other providers container.Register <IDatabaseProvider>(made: Made.Of(() => new SqlServerDatabaseProvider()), reuse: Reuse.Singleton); //database context container.Register <IDatabaseContext>(made: Made.Of(() => DatabaseContextManager.GetDatabaseContext()), reuse: Reuse.InWebRequest); //and respositories container.Register(typeof(IDataRepository <>), typeof(EntityRepository <>), made: Made.Of(FactoryMethod.ConstructorWithResolvableArguments), reuse: Reuse.InResolutionScope); var asm = AssemblyLoader.LoadBinDirectoryAssemblies(); //services //to register services, we need to get all types from services assembly and register each of them; var serviceAssembly = asm.First(x => x.FullName.Contains("mobSocial.Services")); var serviceTypes = serviceAssembly.GetTypes(). Where(type => type.IsPublic && // get public types !type.IsAbstract && // which are not interfaces nor abstract type.GetInterfaces().Length != 0); // which implementing some interface(s) container.RegisterMany(serviceTypes, reuse: Reuse.InResolutionScope); //we need a trasient reporter service rather than singleton container.Register <IVerboseReporterService, VerboseReporterService>(reuse: Reuse.InWebRequest, ifAlreadyRegistered: IfAlreadyRegistered.Replace); //settings var allSettingTypes = TypeFinder.ClassesOfType <ISettingGroup>(); foreach (var settingType in allSettingTypes) { var type = settingType; container.RegisterDelegate(type, resolver => { var instance = (ISettingGroup)Activator.CreateInstance(type); resolver.Resolve <ISettingService>().LoadSettings(instance); return(instance); }, reuse: Reuse.Singleton); } //and ofcourse the page generator container.Register <IPageGenerator, PageGenerator>(reuse: Reuse.Singleton); //event publishers and consumers container.Register <IEventPublisherService, EventPublisherService>(reuse: Reuse.Singleton); //all consumers which are not interfaces //find all event consumer types var allConsumerTypes = asm .Where(x => x.FullName.StartsWith("mobSocial")) .SelectMany(x => { try { return(x.GetTypes()); } catch { return(new Type[0]); } }) .Where(type => type.IsPublic && // get public types type.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEventConsumer <>)) && !type.IsAbstract); // which implementing some interface(s) //all consumers which are not interfaces container.RegisterMany(allConsumerTypes); //user id provider for SignalR container.Register <IUserIdProvider, SignalRUserIdProvider>(); //register authentication service inwebrequest container.Register <IAuthenticationService, AuthenticationService>(reuse: Reuse.InWebRequest, ifAlreadyRegistered: IfAlreadyRegistered.Replace); //overridable providers container.Register <IRoleNameProvider, RoleNameProvider>(reuse: Reuse.Singleton); }