Exemplo n.º 1
0
        /// <summary>
        /// Method to check the validation while fetching the order
        /// </summary>
        /// <param name="response"></param>
        /// <param name="orderSearch"></param>
        /// <returns></returns>
        private ListResponse ValidateOrderSearch(ListResponse listResponse, OrderSearch orderSearch)
        {
            if (orderSearch.PageNumber <= 0)
            {
                listResponse.SetError(ErrorCodes.INVALID_PAGE_NO_Required);
            }
            if (orderSearch.PageSize <= 0)
            {
                listResponse.SetError(ErrorCodes.INVALID_PAGE_SIZE_Required);
            }

            return(listResponse);
        }
        public async Task <IListResponse <ServiceStatusDetailDto> > GetServiceStatusesAsync(string userName)
        {
            Logger?.LogDebug("'{0}' has been invoked", nameof(GetServiceStatusesAsync));

            var response = new ListResponse <ServiceStatusDetailDto>();

            try
            {
                var user = await DbContext.GetUserAsync(userName);

                if (user == null)
                {
                    Logger?.LogInformation("There isn't data for user '{0}'", userName);

                    return(new ListResponse <ServiceStatusDetailDto>());
                }
                else
                {
                    response.Model = await DbContext.GetServiceStatuses(user).ToListAsync();

                    Logger?.LogInformation("The service status details for '{0}' user were loaded successfully", userName);
                }
            }
            catch (Exception ex)
            {
                response.SetError(Logger, nameof(GetServiceStatusesAsync), ex);
            }

            return(response);
        }
Exemplo n.º 3
0
        public async Task <IListResponse <vmMemberContactListResponse> > GetMemberContactListByCreatedAsync(int createdBy)
        {
            var response = new ListResponse <vmMemberContactListResponse>();

            try
            {
                if (createdBy == 0)
                {
                    var listMemberContactFromDb = await MemberContactRepository.GetListMemberContactAsync(createdBy);

                    response.Model   = _mapper.Map <IEnumerable <MemberContact>, IEnumerable <vmMemberContactListResponse> >(listMemberContactFromDb);
                    response.Message = ResponseMessageDisplay.Success;
                }
                else
                {
                    response.DidError     = true;
                    response.ErrorMessage = "createdBy must be greater than 0.";
                }
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Exemplo n.º 4
0
        public async Task <IListResponse <ServiceStatusDetailInfo> > GetServiceStatusesAsync(Guid userID)
        {
            Logger?.LogDebug("'{0}' has been invoked", nameof(GetServiceStatusesAsync));

            var response = new ListResponse <ServiceStatusDetailInfo>();

            try
            {
                response.Model = await DbContext.GetServiceStatuses(userID).ToListAsync();

                if (response.Model?.Count() == 0)
                {
                    Logger?.LogInformation("There is no data for user with ID '{0}'", userID);
                }
                else
                {
                    Logger?.LogInformation("The service status details for user with ID '{0}' were loaded successfully", userID);
                }
            }
            catch (Exception ex)
            {
                response.SetError(Logger, nameof(GetServiceStatusesAsync), ex);
            }

            return(response);
        }
Exemplo n.º 5
0
        public async Task <IListResponse <User> > GetUsersAsync(int pageSize = 0, int pageNumber = 0)
        {
            Logger?.LogInformation(CreateInvokedMethodLog(MethodBase.GetCurrentMethod().ReflectedType.FullName));

            var response = new ListResponse <User> ();

            try {
                response.Model = await UserRepository.GetAll(pageSize, pageNumber).ToListAsync();
            }
            catch (Exception ex) {
                response.SetError(ex, Logger);
            }

            return(response);
        }
        public async Task <IListResponse <Employee> > GetEmployeesAsync(int pageSize = 0, int pageNumber = 0)
        {
            Logger?.LogInformation("{0} has been invoked", nameof(GetEmployeesAsync));

            var response = new ListResponse <Employee>();

            try
            {
                response.Model = await HumanResourcesRepository.GetEmployees(pageSize, pageNumber).ToListAsync();
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response);
        }
Exemplo n.º 7
0
        public async Task <IListResponse <UserModel> > GetUsersWithDetailsAsync(int pageSize = 0, int pageNumber = 0)
        {
            Logger.Info(CreateInvokedMethodLog(MethodBase.GetCurrentMethod().ReflectedType.FullName));

            var response = new ListResponse <UserModel>();

            try
            {
                response.Model = await _userRepository.GetAllWithDetails(pageSize, pageNumber).Select(o => Mapper.Map <UserModel>(o)).ToListAsync();
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response);
        }
Exemplo n.º 8
0
        public async Task <IListResponse <Employee> > GetEmployeesAsync(int pageSize = 0, int pageNumber = 0)
        {
            Logger?.LogInformation("{0} has been invoked", nameof(GetEmployeesAsync));

            var response = new ListResponse <Employee>();

            try
            {
                response.Model = await DbContext.Employees.Paging(pageSize, pageNumber).ToListAsync();
            }
            catch (Exception ex)
            {
                response.SetError(Logger, nameof(GetEmployeesAsync), ex);
            }

            return(response);
        }
Exemplo n.º 9
0
        public async Task <IListResponse <Student> > GetStudentsWithCoursesAsync()
        {
            Logger?.LogDebug("{0} has been invoked", nameof(GetStudentsWithCoursesAsync));

            var response = new ListResponse <Student>();

            try
            {
                response.Model = await UnitOfWork.Students.GetStudentsWithCourses();
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> GetImportedDatabasesAsync()
        {
            Logger?.LogDebug("'{0}' has been invoked", nameof(GetImportedDatabasesAsync));

            var response = new ListResponse <ImportedDatabase>();

            try
            {
                response.Model = await DbService.GetImportedDatabasesAsync();
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response.ToHttpResponse());
        }
Exemplo n.º 11
0
        public async Task <IListResponse <vmTransactionListFullRequest> > GetListTransactionFullRangeAsync(int createdBy, DateTime startDate, DateTime endDate)
        {
            var response = new ListResponse <vmTransactionListFullRequest>();

            try
            {
                var listTransactionFromDb = await TransactionRepository.GetListFullTransactionRangeAsync(createdBy, startDate, endDate);

                response.Model   = _mapper.Map <IEnumerable <Transaction>, IEnumerable <vmTransactionListFullRequest> >(listTransactionFromDb);
                response.Message = ResponseMessageDisplay.Success;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Exemplo n.º 12
0
        public async Task <IListResponse <vmPaymentMethodType> > PreparePaymentMethodRelatedRequestAsync()
        {
            var response = new ListResponse <vmPaymentMethodType>();

            try
            {
                var listPaymentMethodTypeFromDb = await PaymentMethodTypeRepository.GetListPaymentMethodTypeAsync();

                response.Model   = _mapper.Map <IEnumerable <PaymentMethodType>, IEnumerable <vmPaymentMethodType> >(listPaymentMethodTypeFromDb);
                response.Message = ResponseMessageDisplay.Success;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Exemplo n.º 13
0
        public async Task <IListResponse <vmDrugPropertiesResponse> > GetListDrugPropertiesAsync()
        {
            var response = new ListResponse <vmDrugPropertiesResponse>();

            try
            {
                var listDrugPropertiesFromDb = await this._drugPropertiesRepo.GetListDrugPropertiesAsync();

                response.Model   = _mapper.Map <IEnumerable <DrugProperties>, IEnumerable <vmDrugPropertiesResponse> >(listDrugPropertiesFromDb);
                response.Message = ResponseMessageDisplay.Success;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Exemplo n.º 14
0
        public async Task <IListResponse <vmPaymentPayorListRequest> > GetListPaymentPayorAsync(int createdBy)
        {
            var response = new ListResponse <vmPaymentPayorListRequest>();

            try
            {
                var listPaymentPayorFromDb = await PaymentPayorRepository.GetListPaymentPayorAsync(createdBy, includeRelationship : true);

                response.Model   = _mapper.Map <IEnumerable <PaymentPayor>, IEnumerable <vmPaymentPayorListRequest> >(listPaymentPayorFromDb);
                response.Message = ResponseMessageDisplay.Success;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Exemplo n.º 15
0
        public async Task <IListResponse <vmTransactionCategoryList> > GetListTransactionCategoryAsync()
        {
            var response = new ListResponse <vmTransactionCategoryList>();

            try
            {
                var listTransactionCategoryFromDb = await TransactionCategoryRepository.GetListTransactionCategoryAsync();

                response.Model   = _mapper.Map <IEnumerable <TransactionCategory>, IEnumerable <vmTransactionCategoryList> >(listTransactionCategoryFromDb);
                response.Message = ResponseMessageDisplay.Success;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Exemplo n.º 16
0
        public async Task <IListResponse <ServiceWatcherItemDto> > GetActiveServiceWatcherItemsAsync()
        {
            Logger?.LogDebug("'{0}' has been invoked", nameof(GetActiveServiceWatcherItemsAsync));

            var response = new ListResponse <ServiceWatcherItemDto>();

            try
            {
                response.Model = await DbContext.GetActiveServiceWatcherItems().ToListAsync();

                Logger?.LogInformation("The service watch items were loaded successfully");
            }
            catch (Exception ex)
            {
                response.SetError(Logger, nameof(GetActiveServiceWatcherItemsAsync), ex);
            }

            return(response);
        }
Exemplo n.º 17
0
        public async Task<ListResponse<BancoZiPago>> ListarBancoZiPagoAsync(Logger logger)
        {
            ListResponse<BancoZiPago> response = new ListResponse<BancoZiPago>();
            logger.Info("[{0}] | BancoZiPago: [{1}] | Inicio.", nameof(ListarBancoZiPagoAsync));
            try
            {
                var query = DbContext.BancosZiPago.OrderBy(item => item.NombreLargo);

                response.Model = await query.ToListAsync();

                logger.Info("[{0}] | BancoZiPago: [{1}] | Mensaje: [Realizado].", nameof(ListarBancoZiPagoAsync));
            }
            catch (Exception ex)
            {
                response.Model = null;
                response.SetError(logger, nameof(ListarBancoZiPagoAsync), nameof(BancoZiPago), ex);
            }
            return response;
        }
Exemplo n.º 18
0
        public async Task <ListResponse <UbigeoZiPago> > ListarUbigeoZiPagoAsync(Logger logger, string CodigoUbigeoPadre)
        {
            ListResponse <UbigeoZiPago> response = new ListResponse <UbigeoZiPago>();

            logger.Info("[{0}] | UbigeoZiPago: [{1}] | Inicio.", nameof(ListarUbigeoZiPagoAsync), CodigoUbigeoPadre);
            try
            {
                response.Model = await DbContext.UbigeosZiPago
                                 .Where(item => item.CodigoUbigeoPadre == CodigoUbigeoPadre)
                                 .OrderBy(item => item.Nombre).ToListAsync();

                logger.Info("[{0}] | UbigeoZiPago: [{1}] | Mensaje: [Realizado].", nameof(ListarUbigeoZiPagoAsync), CodigoUbigeoPadre);
            }
            catch (Exception ex)
            {
                response.Model = null;
                response.SetError(logger, nameof(ListarUbigeoZiPagoAsync), nameof(UbigeoZiPago), ex);
            }
            return(response);
        }
Exemplo n.º 19
0
        public async Task <ListResponse <TablaDetalle> > ListarTablaDetalleAsync(Logger logger, string CodTabla)
        {
            ListResponse <TablaDetalle> response = new ListResponse <TablaDetalle>();

            logger.Info("[{0}] | TablaDetalle: [{1}] | Inicio.", nameof(ListarTablaDetalleAsync), CodTabla);
            try
            {
                var query = DbContext.TablasDetalle.Where(item => item.Cod_Tabla == CodTabla).OrderBy(item => item.Descr_Valor);

                response.Model = await query.ToListAsync();

                logger.Info("[{0}] | TablaDetalle: [{1}] | Mensaje: [Realizado].", nameof(ListarTablaDetalleAsync), CodTabla);
            }
            catch (Exception ex)
            {
                response.Model = null;
                response.SetError(logger, nameof(ListarTablaDetalleAsync), nameof(TablaDetalle), ex);
            }
            return(response);
        }
Exemplo n.º 20
0
        public ListResponse<EventCategory> ListEventCategories()
        {
            var response = new ListResponse<EventCategory>();

            try
            {
                var clnEventCategories = this.StatWinnerDatabase.GetCollection<EventCategoryDBEntity>("EventCategories");
                var sortDefinition = new SortDefinitionBuilder<EventCategoryDBEntity>();
                var lst = clnEventCategories.Find(_ => true)
                    .Sort(sortDefinition.Ascending(s => s.Name))
                    .ToListAsync()
                    .Result.Select(EventManagementFactory.ConvertToEventCategory)
                    .ToList();
                response.Result = lst;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return response;
        }
Exemplo n.º 21
0
        public async Task <IListResponse <ProductModel> > AddProductsAsync(IEnumerable <ProductModel> details)
        {
            var response = new ListResponse <ProductModel>();

            using (var transaction = DbContext.Database.BeginTransaction())
            {
                try
                {
                    await ProductRepository.AddAsync(details.Select(o => Mapper.Map <Product>(o)).ToAsyncEnumerable());

                    transaction.Commit();

                    response.Model = details;
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    response.SetError(ex, Logger);
                }
            }

            return(response);
        }
        public async Task <IListResponse <ProductInventory> > GetProductInventories(int?productID = null, string locationID = null)
        {
            Logger?.LogInformation("{0} has been invoked", nameof(GetProductInventories));

            var response = new ListResponse <ProductInventory>();

            try
            {
                // Get query
                var query = DbContext.GetProductInventories(productID, locationID);

                // Retrieve items, set model for response
                var list = await query.ToListAsync();

                // Sorting results
                response.Model = list.OrderByDescending(item => item.CreationDateTime);
            }
            catch (Exception ex)
            {
                response.SetError(Logger, nameof(GetProductInventories), ex);
            }

            return(response);
        }
Exemplo n.º 23
0
        public async Task <IListResponse <ProductInventory> > GetInventoryByProduct(Int32?productID)
        {
            Logger?.LogInformation("{0} has been invoked", nameof(GetInventoryByProduct));

            var response = new ListResponse <ProductInventory>();

            try
            {
                // Get query
                var query = ProductionRepository.GetProductInventories(productID: productID);

                // Retrieve items, set model for response
                var list = await query.ToListAsync();

                // Sorting results
                response.Model = list.OrderByDescending(item => item.CreationDateTime);
            }
            catch (Exception ex)
            {
                response.SetError(ex, Logger);
            }

            return(response);
        }
        public ListResponse<Country> LoadAllCountries()
        {
            var response = new ListResponse<Country>();

            try
            {
                var mongoCollection = this.StatWinnerDatabase.GetCollection<CountryEntity>("Countries");
                var sortDefinition = new SortDefinitionBuilder<CountryEntity>();
                var lst =
                    mongoCollection.Find(_ => true)
                        .Sort(sortDefinition.Ascending("name"))
                        .ToListAsync()
                        .Result.Select(UserAccountManagementFactory.convertToCountry)
                        .ToList();
                response.Result = lst;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }
            return response;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Loads the list of notification events
        /// </summary>
        /// <returns></returns>
        public ListResponse<EventEntity> LoadNotificationEvents()
        {
            var response = new ListResponse<EventEntity>();

            try
            {
                var clnEvents = this.StatWinnerDatabase.GetCollection<EventDbEntity>("NotificationEvents");
                var sortDefinition = new SortDefinitionBuilder<EventDbEntity>();
                var events =
                    clnEvents.Find(_ => true).Sort(sortDefinition.Ascending(r => r.EventKey)).ToListAsync().Result.Select(EventManagementFactory.ConvertToEvent).ToList();


                //Set Event Categories
                var clnEventCategories =
                    this.StatWinnerDatabase.GetCollection<EventCategoryDBEntity>("EventCategories");

                var evenTcategoriIds =
                    events.Where(e => !e.EventCategoryId.IsNullOrEmpty()).Select(e => ObjectId.Parse(e.EventCategoryId)).ToList();

                var eventCategoriesFilter = Builders<EventCategoryDBEntity>.Filter.In("_id", evenTcategoriIds);
                var eventCategories =
                    clnEventCategories.Find(eventCategoriesFilter).ToListAsync().Result.ToList();
                events.ForEach(ev => ev.EventCategoryName = (eventCategories.Single(ec => ec.Id.ToString() == ev.EventCategoryId).Name));

                response.Result = events;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return response;
        }