Ejemplo n.º 1
0
 public ImageUploadController(DefaultDataContext context,
                              IHostingEnvironment hostingEnvironment, IImageRepository repository)
 {
     _ctx = context;
     _hostingEnvironment = hostingEnvironment;
     _repo = repository;
 }
Ejemplo n.º 2
0
 public static void Init()
 {
     lock (_lock)
     {
         var _uow        = new UnitOfWork(new DefaultDataContext());
         var dataContext = new DefaultDataContext();
         var items       = dataContext.Configurations.ToList();
         if (items != null)
         {
             _data.Clear();
             foreach (var m in items)
             {
                 if (_data.Keys.Any(x => x == m.Key))
                 {
                     continue;
                 }
                 _data.Add(m.Key, m);
             }
         }
     }
 }
Ejemplo n.º 3
0
        private static void InsertSeedData(DefaultDataContext context)
        {
            // AllRegion(context);


            var locations = $"{initialDir}locations/";

            if (!context.Countries.Any())
            {
                using (StreamReader jsonData = new StreamReader(Path.Combine(Path.GetFullPath($"{locations}Countries.json")))){
                    var Countries = JsonConvert.DeserializeObject <List <Country> >(jsonData.ReadToEnd());
                    Countries.ForEach(s => context.Countries.Add(s));
                }

                using (StreamReader jsonData = new StreamReader(Path.Combine(Path.GetFullPath($"{locations}States.json")))){
                    var States = JsonConvert.DeserializeObject <List <State> >(jsonData.ReadToEnd());
                    States.ForEach(s => context.States.Add(s));
                }

                context.SaveChanges();
            }

            // context.SaveChanges();
        }
Ejemplo n.º 4
0
 public ItemCountService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 5
0
        public static async Task OnDeletingOrganizationRole(IDeletingEntry <OrganizationRole, DbContext> entity, DefaultDataContext DataContext)
        {
            var organizationTypeRoles = await DataContext.OrganizationTypeRoles.Where(o => o.OrganizationRoleId == entity.Entity.Id).ToListAsync();

            if (organizationTypeRoles.Count > 0)
            {
                DataContext.OrganizationTypeRoles.RemoveRange(organizationTypeRoles);
            }
        }
Ejemplo n.º 6
0
 public LoginLogService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 7
0
 public CategoryRepository(DefaultDataContext ctx)
 {
     _ctx = ctx;
 }
Ejemplo n.º 8
0
 public BasketController(DefaultDataContext context)
 {
     _ctx = context;
 }
Ejemplo n.º 9
0
        public static async Task OnDeletingWork(IDeletingEntry <Work, DbContext> entity, DefaultDataContext DataContext)
        {
            var workVerification = await DataContext.WorkVerifications.Where(w => w.WorkId == entity.Entity.Id).ToListAsync();

            if (workVerification.Count > 0)
            {
                DataContext.WorkVerifications.RemoveRange(workVerification);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// When deleting this user delete the following:
        /// </summary>
        /// <param name="entity"> </param>
        /// <param name="DataContext"></param>
        /// <returns>Void</returns>
        public static async Task OnDeletingUser(IDeletingEntry <User, DbContext> entity, DefaultDataContext DataContext)
        {
            // Delete Address of user
            var address = await DataContext.Addresses.SingleOrDefaultAsync(c => c.Type == nameof(User) && c.TypeId == entity.Entity.Id);

            if (address != null)
            {
                DataContext.Addresses.Remove(address);
            }

            // Delete Contact of user
            var contact = await DataContext.Contacts.SingleOrDefaultAsync(c => c.Type == nameof(User) && c.TypeId == entity.Entity.Id);

            if (contact != null)
            {
                DataContext.Contacts.Remove(contact);
            }

            // Delete collections of user that starts its own deleting
            var collections = await DataContext.Collections.SingleOrDefaultAsync(c => c.Type == nameof(User) && c.TypeId == entity.Entity.Id);

            if (collections != null)
            {
                DataContext.Collections.Remove(collections);
            }
        }
Ejemplo n.º 11
0
 public DictService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 12
0
 public FriendRelationshipService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 13
0
 public QrcodeService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 14
0
 public DepartmentService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 15
0
 public RoleService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 16
0
 public ConfigurationService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 17
0
 public UserRepository()
 {
     _ctx         = new DefaultDataContext();
     _userManager = new UserManager <IdentityUser>(new UserStore <IdentityUser>(_ctx));
 }
Ejemplo n.º 18
0
        public static async Task OnDeletingCollection(IDeletingEntry <Collection, DbContext> entity, DefaultDataContext DataContext)
        {
            var problems = await DataContext.Problems.Where(p => p.Type == nameof(entity.Entity.Type) && p.TypeId == entity.Entity.TypeId).ToListAsync();

            if (problems.Count > 0)
            {
                DataContext.Problems.RemoveRange(problems);
            }

            var ideas = await DataContext.Ideas.Where(p => p.Type == nameof(entity.Entity.Type) && p.TypeId == entity.Entity.TypeId).ToListAsync();

            if (ideas.Count > 0)
            {
                DataContext.Ideas.RemoveRange(ideas);
            }

            var projects = await DataContext.Projects.Where(p => p.Type == nameof(entity.Entity.Type) && p.TypeId == entity.Entity.TypeId).ToListAsync();

            if (projects.Count > 0)
            {
                DataContext.Projects.RemoveRange(projects);
            }

            var photos = await DataContext.Photos.Where(p => p.Type == nameof(entity.Entity.Type) && p.TypeId == entity.Entity.TypeId).ToListAsync();

            if (photos.Count > 0)
            {
                DataContext.Photos.RemoveRange(photos);
            }

            var work = await DataContext.Works.Where(p => p.UserId == entity.Entity.TypeId).ToListAsync();

            if (work.Count > 0)
            {
                DataContext.Works.RemoveRange(work);
            }
        }
Ejemplo n.º 19
0
 public UserService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 20
0
 public ServiceBase(DefaultDataContext dbcontext)
 {
     this.uow = new UnitOfWork(dbcontext);
 }
Ejemplo n.º 21
0
        public static async Task OnDeletingOrganization(IDeletingEntry <OrganizationDetail, DbContext> entity, DefaultDataContext DataContext)
        {
            var address = await DataContext.Addresses.SingleOrDefaultAsync(c => c.Type == nameof(OrganizationDetail) && c.TypeId == entity.Entity.Id);

            if (address != null)
            {
                DataContext.Addresses.Remove(address);
            }

            var contact = await DataContext.Contacts.SingleOrDefaultAsync(c => c.Type == nameof(OrganizationDetail) && c.TypeId == entity.Entity.Id);

            if (contact != null)
            {
                DataContext.Contacts.Remove(contact);
            }

            var collections = await DataContext.Collections.SingleOrDefaultAsync(c => c.Type == nameof(OrganizationDetail) && c.TypeId == entity.Entity.Id);

            if (collections != null)
            {
                DataContext.Collections.Remove(collections);
            }

            var organizationTypeRoles = await DataContext.OrganizationTypeRoles.Where(p => p.OrganizationId == entity.Entity.Id).ToListAsync();

            if (organizationTypeRoles.Count > 0)
            {
                DataContext.OrganizationTypeRoles.RemoveRange(organizationTypeRoles);
            }

            var organizationRoles = await DataContext.OrganizationRoles.Where(p => p.BranchId == entity.Entity.Id).ToListAsync();

            if (organizationRoles.Count > 0)
            {
                DataContext.OrganizationRoles.RemoveRange(organizationRoles);
            }

            var organizationVerification = await DataContext.OrganizationVerifications.Where(p => p.OrganizationDetailId == entity.Entity.Id).ToListAsync();

            if (organizationVerification.Count > 0)
            {
                DataContext.OrganizationVerifications.RemoveRange(organizationVerification);
            }

            if (entity.Entity.HeadQuaters == entity.Entity.Id)
            {
                var branches = await DataContext.OrganizationDetails.Where(p => p.HeadQuaters == entity.Entity.Id).ToListAsync();

                if (branches.Count > 0)
                {
                    DataContext.OrganizationDetails.RemoveRange(branches);
                }
            }
        }
        public static async Task OnDeletingCollection(IDeletingEntry <Collection, DbContext> entity, DefaultDataContext DataContext)
        {
            var photos = await DataContext.Photos.Where(p => p.Type == nameof(entity.Entity.Type) && p.TypeId == entity.Entity.TypeId).ToListAsync();

            if (photos.Count > 0)
            {
                DataContext.Photos.RemoveRange(photos);
            }
        }
Ejemplo n.º 23
0
 public NewsViewRecordService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 24
0
 public ImageRepository(DefaultDataContext context)
 {
     _ctx = context;
 }
Ejemplo n.º 25
0
        public static async Task OnDeletingProblem(IDeletingEntry <Problem, DbContext> entity, DefaultDataContext DataContext)
        {
            var ecoDetail = await DataContext.EcoDetails.SingleOrDefaultAsync(e => e.Type == nameof(Problem) && e.TypeId == entity.Entity.Id);

            if (ecoDetail != null)
            {
                DataContext.EcoDetails.Remove(ecoDetail);
            }


            var address = await DataContext.Addresses.SingleOrDefaultAsync(e => e.Type == nameof(Problem) && e.TypeId == entity.Entity.Id);

            if (address != null)
            {
                DataContext.Addresses.Remove(address);
            }


            var projectsUrls = await DataContext.ProjectUrls.Where(p => p.Type == nameof(Problem) && p.TypeId == entity.Entity.Id).ToListAsync();

            if (projectsUrls.Count > 0)
            {
                DataContext.ProjectUrls.RemoveRange(projectsUrls);
            }

            var photos = await DataContext.Photos.Where(p => p.Type == nameof(Problem) && p.TypeId == entity.Entity.Id).ToListAsync();

            if (photos.Count > 0)
            {
                DataContext.Photos.RemoveRange(photos);
            }

            var votes = await DataContext.Votes.Where(p => p.Type == nameof(Problem) && p.TypeId == entity.Entity.Id).ToListAsync();

            if (votes.Count > 0)
            {
                DataContext.Votes.RemoveRange(votes);
            }

            var comments = await DataContext.Comments.Where(p => p.Type == nameof(Problem) && p.TypeId == entity.Entity.Id).ToListAsync();

            if (comments.Count > 0)
            {
                DataContext.Comments.RemoveRange(comments);
            }
        }
Ejemplo n.º 26
0
 public NewsCategoryService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 27
0
 public MenuService(DefaultDataContext dbcontext) : base(dbcontext)
 {
 }
Ejemplo n.º 28
0
        /// <summary>
        /// When deleting this user delete the following:
        /// </summary>
        /// <param name="entity"> </param>
        /// <param name="DataContext"></param>
        /// <returns>Void</returns>
        public static async Task OnDeletingUser(IDeletingEntry <User, DbContext> entity, DefaultDataContext DataContext)
        {
            // Delete Address of user
            var address = await DataContext.Addresses.SingleOrDefaultAsync(c => c.Type == nameof(User) && c.TypeId == entity.Entity.Id);

            if (address != null)
            {
                DataContext.Addresses.Remove(address);
            }

            // Delete Contact of user
            var contact = await DataContext.Contacts.SingleOrDefaultAsync(c => c.Type == nameof(User) && c.TypeId == entity.Entity.Id);

            if (contact != null)
            {
                DataContext.Contacts.Remove(contact);
            }

            // Delete collections of user that starts its own deleting
            var collections = await DataContext.Collections.SingleOrDefaultAsync(c => c.Type == nameof(User) && c.TypeId == entity.Entity.Id);

            if (collections != null)
            {
                DataContext.Collections.Remove(collections);
            }



            var organizationTypeRoles = await DataContext.OrganizationTypeRoles.Where(p => p.Type == nameof(User) && p.TypeId == entity.Entity.Id).ToListAsync();

            if (organizationTypeRoles.Count > 0)
            {
                DataContext.OrganizationTypeRoles.RemoveRange(organizationTypeRoles);
            }
        }