Beispiel #1
0
        /// <summary>
        /// Gets list object of the table CompanyApplication.
        /// </summary>
        /// <param name="paginationDto">Attributes to apply the pagination.</param>
        /// <param name="listCompanyApplicationDto">List that contains the DTOs from CompanyApplication table that filter the query.</param>
        /// <returns>List object of the table CompanyApplication.</returns>
        /// <author>Mauricio Suarez.</author>
        private List <CompanyApplicationDto> ExecutePaginated(PaginationDto paginationDto, List <CompanyApplicationDto> listCompanyApplicationDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())
            {
                if (string.IsNullOrEmpty(paginationDto.SortExpression))
                {
                    paginationDto.SortExpression = "IdCompanyApplication";
                    paginationDto.SortDirection  = "ASC";
                }

                if (paginationDto.PageSize == 0 && paginationDto.CurrentPage == 0)
                {
                    paginationDto.PageSize = int.MaxValue;
                }

                var predicate = ConditionalQuery.GeneratePredicateQuery <CompanyApplication, CompanyApplicationDto>(listCompanyApplicationDto);

                return(context.CompanyApplication.AsExpandable()
                       .Include(ConditionalQuery.GenerateIncludes(listCompanyApplicationDto))
                       .Where(predicate).AsParallel()
                       .OrderBy(paginationDto.SortExpression + " " + paginationDto.SortDirection)
                       .Skip(paginationDto.CurrentPage * paginationDto.PageSize)
                       .Take(paginationDto.PageSize)
                       .Select(Mapper.Map <CompanyApplication, CompanyApplicationDto>).ToList());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Number of rows affected.
        /// </summary>
        /// <param name="listApplicationDto">List that contains the DTOs from Application table that filter the query.</param>
        /// <returns>Number of rows affected.</returns>
        /// <author>Mauricio Suárez.</author>
        public int GetApplicationCount(List <ApplicationDto> listApplicationDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())//GetDataBaseContext())
            {
                var predicate = ConditionalQuery.GeneratePredicateQuery <Application, ApplicationDto>(listApplicationDto);

                return(context.Application.AsExpandable()
                       .Where(predicate).AsParallel()
                       .Count());
            }
        }
        /// <summary>
        /// Number of rows affected.
        /// </summary>
        /// <param name="listNotificationsSettingsDto">List that contains the DTOs from NotificationsSettings table that filter the query.</param>
        /// <returns>Number of rows affected.</returns>
        /// <author>Mauricio Suárez.</author>
        public int GetNotificationsSettingsCount(List <NotificationsSettingsDto> listNotificationsSettingsDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())//GetDataBaseContext())
            {
                var predicate = ConditionalQuery.GeneratePredicateQuery <NotificationsSettings, NotificationsSettingsDto>(listNotificationsSettingsDto);

                return(context.NotificationsSettings.AsExpandable()
                       .Where(predicate).AsParallel()
                       .Count());
            }
        }
Beispiel #4
0
        /// <summary>
        /// Gets list object of the table Application.
        /// </summary>
        /// <param name="listFilterGeneric">List that contains the DTOs from Application table that filter the query.</param>
        /// <returns>List object of the table Application.</returns>
        /// <author>Mauricio Suárez.</author>
        private List <ApplicationDto> ExecuteUnPaginated(List <ApplicationDto> listApplicationDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())//GetDataBaseContext())
            {
                var predicate = ConditionalQuery.GeneratePredicateQuery <Application, ApplicationDto>(listApplicationDto);

                return(context.Application.AsExpandable()
                       .Include(ConditionalQuery.GenerateIncludes(listApplicationDto))
                       .Where(predicate).AsParallel()
                       .Select(Mapper.Map <Application, ApplicationDto>).ToList());
            }
        }
Beispiel #5
0
        /// <summary>
        /// Delete rows from table CompanyApplication.
        /// </summary>
        /// <param name="listCompanyApplicationDto">List that contains the DTOs from CompanyApplication table that filter the query.</param>
        /// <returns>Comfirm execute command.</returns>
        /// <author>Mauricio Suarez.</author>
        public bool DeleteCompanyApplication(List <CompanyApplicationDto> listCompanyApplicationDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())
            {
                var predicate = ConditionalQuery.GeneratePredicateQuery <CompanyApplication, CompanyApplicationDto>(listCompanyApplicationDto);

                context.CompanyApplication.RemoveRange(context.CompanyApplication.AsExpandable().Where(predicate));
                context.SaveChanges();

                return(true);
            }
        }
Beispiel #6
0
        public List <ApplicationDto> GetApplicationByUser(List <ApplicationUserRoleDto> listApplicationUserRoleDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())//GetDataBaseContext())
            {
                var predicate = ConditionalQuery.GeneratePredicateQuery <ApplicationUserRole, ApplicationUserRoleDto>(listApplicationUserRoleDto);

                return((List <ApplicationDto>)UtilitiesObject.RemoveOtherObjects(context.ApplicationUserRole
                                                                                 .Include(ConditionalQuery.GenerateIncludes(listApplicationUserRoleDto)).AsExpandable()
                                                                                 .Where(predicate).AsParallel()
                                                                                 .Select(data => data.ApplicationRole.Application)
                                                                                 .Distinct()
                                                                                 .Select(Mapper.Map <Application, ApplicationDto>).ToList()));
            }
        }
        /// <summary>
        /// Save or update records for the table
        /// </summary>
        /// <param name="listDataUserApplication">List of data to store UserApplication.</param>
        /// <returns>The result of processing the list.</returns>
        /// <author>Mauricio Suárez.</author>
        public List <UserApplicationDto> SaveUserApplication(List <UserApplicationDto> listUserApplicationDto)
        {
            List <UserApplication> listSaleResult = new List <UserApplication>();

            using (SecurityManagmentEntities context = new SecurityManagmentEntities())
            {
                ObjectContext objectContext     = ((IObjectContextAdapter)context).ObjectContext;
                ObjectSet <UserApplication> set = objectContext.CreateObjectSet <UserApplication>();
                string[] entitySaleKeys         = set.EntitySet.ElementType.KeyMembers.Select(k => k.Name).ToArray();

                bool[] resultValidateInsertOrUpdate = ConditionalQuery.ValidatePrimaryKeyValueInDto(listUserApplicationDto, entitySaleKeys);

                int resultValidateInsertOrUpdateCount = resultValidateInsertOrUpdate.Count();

                int i = 0;
                foreach (UserApplicationDto dtoSale in listUserApplicationDto)
                {
                    UserApplication entitySale = Mapper.Map <UserApplicationDto, UserApplication>(dtoSale);

                    if (resultValidateInsertOrUpdateCount > 0)
                    {
                        if (resultValidateInsertOrUpdate[i])
                        {
                            context.UserApplication.Attach(entitySale);
                            context.Entry(entitySale).State = System.Data.Entity.EntityState.Modified;
                        }
                        else
                        {
                            context.UserApplication.Add(entitySale);
                        }
                    }
                    else
                    {
                        context.UserApplication.Add(entitySale);
                    }

                    listSaleResult.Add(entitySale);
                    i++;
                }

                context.SaveChanges();
            }

            listUserApplicationDto = null;
            return(listSaleResult.Select(Mapper.Map <UserApplication, UserApplicationDto>).ToList());
        }
        public List <NotificationsSettingsDto> GetUpdateNotifications(List <NotificationsSettingsDto> listFilterNotificationsSettings, bool summaryView)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())//GetDataBaseContext())
            {
                List <ObjectParameter> parameters = new List <ObjectParameter> {
                    new ObjectParameter("StartDate", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second))
                };

                parameters.AddRange(ConditionalQuery.GenerateParametersConditionalQuery(listFilterNotificationsSettings));
                string filterDate = (summaryView ? "SummaryEndDate" : "DashboardEndDate");

                return(context.NotificationsSettings
                       .Include(ConditionalQuery.GenerateIncludes(listFilterNotificationsSettings))
                       .Where("(" + ConditionalQuery.GenerateConditionalQuery(listFilterNotificationsSettings) + ") AND it." + filterDate + " >= @StartDate", parameters.ToArray()).AsParallel()
                       .Select(Mapper.Map <NotificationsSettings, NotificationsSettingsDto>).ToList());
            }
        }
Beispiel #9
0
        /// <summary>
        /// Save or update records for the table
        /// </summary>
        /// <param name="listDataApplication">List of data to store Application.</param>
        /// <returns>The result of processing the list.</returns>
        /// <author>Mauricio Suárez.</author>
        public bool SaveApplication(List <ApplicationDto> listApplicationDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())
            {
                ObjectContext           objectContext = ((IObjectContextAdapter)context).ObjectContext;
                ObjectSet <Application> set           = objectContext.CreateObjectSet <Application>();
                string[] entityOrderDetailKeys        = set.EntitySet.ElementType.KeyMembers.Select(k => k.Name).ToArray();

                bool[] resultValidateInsertOrUpdate = ConditionalQuery.ValidatePrimaryKeyValueInDto(listApplicationDto, entityOrderDetailKeys);

                int resultValidateInsertOrUpdateCount = resultValidateInsertOrUpdate.Count();

                int i = 0;
                foreach (ApplicationDto dtoApplication in listApplicationDto)
                {
                    if (resultValidateInsertOrUpdateCount > 0)
                    {
                        Application entityOrderDetail = null;
                        if (resultValidateInsertOrUpdate[i])
                        {
                            entityOrderDetail = Mapper.Map <ApplicationDto, Application>(dtoApplication);
                            context.Entry(entityOrderDetail).State = System.Data.Entity.EntityState.Modified;
                            context.Application.Attach(entityOrderDetail);
                        }
                        else
                        {
                            context.Application.Add(Mapper.Map <ApplicationDto, Application>(dtoApplication));
                        }
                    }
                    else
                    {
                        context.Application.Add(Mapper.Map <ApplicationDto, Application>(dtoApplication));
                    }
                    i++;
                }

                context.SaveChanges();
            }

            return(true);
        }
Beispiel #10
0
        /// <summary>
        /// Gets list object of the table Application.
        /// </summary>
        /// <param name="paginationDto">Attributes to apply the pagination.</param>
        /// <param name="listFilterGeneric">List that contains the DTOs from Application table that filter the query.</param>
        /// <returns>List object of the table Application.</returns>
        /// <author>Mauricio Suárez.</author>
        private List <ApplicationDto> ExecutePaginated(PaginationDto paginationDto, List <ApplicationDto> listApplicationDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())//GetDataBaseContext())
            {
                int skipRol = paginationDto.Skip;

                if (string.IsNullOrEmpty(paginationDto.SortExpression))
                {
                    paginationDto.SortExpression = "IdApplication";
                    //paginationDto.SortDirection = SortDirection.Ascending.ToString();
                }

                return(context.Application
                       .Include(ConditionalQuery.GenerateIncludes(listApplicationDto))
                       .Where(ConditionalQuery.GenerateConditionalQuery(listApplicationDto), ConditionalQuery.GenerateParametersConditionalQuery(listApplicationDto)).AsParallel()
                       .AsQueryable()
                       .OrderBy(paginationDto.SortExpression + " " + paginationDto.SortDirectionAbbreviation)
                       .Skip(skipRol)
                       .Take(paginationDto.PageSize)
                       .Select(Mapper.Map <Application, ApplicationDto>).ToList());
            }
        }