Exemple #1
0
    public ListDto <T> FindAll(SearchListDtoArg arg)
    {
        ListDto <SearchListDtoArg> args = new ListDto <SearchListDtoArg>();

        args.Add(arg);
        return(FindAll(args.ToArray()));
    }
Exemple #2
0
        public BaseResponseDto AddEntities <T>(IEnumerable <T> entities, PaginationDto pagination = null)
            where T : EntityDto, new()
        {
            if (!Data.ContainsKey(typeof(T)))
            {
                Data[typeof(T)] = new ListDto
                {
                    PrimaryKey = typeof(T).GetEntityPrimaryKeyName(),
                    List       = new Dictionary <object, EntityDto>()
                };
            }

            var list = Data[typeof(T)].List;

            foreach (var entity in entities)
            {
                list[entity.GetEntityPrimaryKey()] = entity;
            }

            if (pagination != null)
            {
                Data[typeof(T)].Pagination = pagination;
            }

            return(this);
        }
Exemple #3
0
        public void PersistList_OfGivenKey_ClearsTheListExpirationData()
        {
            // ARRANGE
            var list1 = new ListDto {
                Key = "List1", ExpireAt = DateTimeOffset.UtcNow
            };

            list1.Values.Add("value1");
            var list2 = new ListDto {
                Key = "List2", ExpireAt = DateTimeOffset.UtcNow
            };

            list1.Values.Add("value2");
            _realm.Write(() =>
            {
                _realm.Add(list1);
                _realm.Add(list2);
            });


            // ACT
            _transaction.PersistList(list1.Key);
            _transaction.Commit();

            // ASSERT
            var testSet1 = _realm.Find <ListDto>(list1.Key);

            Assert.Null(testSet1.ExpireAt);

            var testSet2 = _realm.Find <ListDto>(list2.Key);

            Assert.NotNull(testSet2.ExpireAt);
        }
Exemple #4
0
        public void ExpireList_SetExpirationDate_ExpirationDataSet()
        {
            // ARRANGE
            var list1 = new ListDto {
                Key = "List1"
            };

            list1.Values.Add("value1");
            var list2 = new ListDto {
                Key = "List2"
            };

            list1.Values.Add("value2");
            _realm.Write(() =>
            {
                _realm.Add(list1);
                _realm.Add(list2);
            });


            // ACT
            _transaction.ExpireList("List1", TimeSpan.FromDays(1));
            _transaction.Commit();

            // ASSERT
            list1 = _realm.Find <ListDto>("List1");
            list2 = _realm.Find <ListDto>("List2");
            Assert.IsNotNull(list1);
            Assert.NotNull(list1.ExpireAt);
            Assert.True(DateTime.UtcNow.AddMinutes(-1) < list1.ExpireAt && list1.ExpireAt <= DateTime.UtcNow.AddDays(1));
            Assert.IsNull(list2.ExpireAt);
        }
Exemple #5
0
        public async Task <IActionResult> GetAll([FromQuery] VendaRequestAllDto requestDto)
        {
            var lista = new ListDto <VendaDto>();

            try
            {
                var response = await _appService.GetAllVendaAsync(requestDto);
            }
            catch (Exception ex)
            {
                var v = new VendaDto()
                {
                    Id      = new Guid("0D4090B2-5687-4938-ABDF-A8DA016EE645"),
                    Product = new Dto.Product.ProductDto()
                    {
                        Id = new Guid("0D4090B2-5687-4938-ABDF-A8DA016EE645"), Description = ex.ToString()
                    },
                    ProductId  = new Guid("0D4090B2-5687-4938-ABDF-A8DA016EE645"),
                    Quantidade = 5
                };

                lista.Items.Add(v);
            }
            return(CreateResponseOnGetAll(lista, _name));
        }
Exemple #6
0
        public void ExpireList_SetsListExpirationData()
        {
            var list1 = new ListDto {
                Item = "List1", Value = "value1"
            };

            _database.JobGraph.InsertOne(list1);

            var list2 = new ListDto {
                Item = "List2", Value = "value2"
            };

            _database.JobGraph.InsertOne(list2);

            Commit(x => x.ExpireList(list1.Item, TimeSpan.FromDays(1)));

            var testList1 = GetTestList(_database, list1.Item);

            Assert.True(DateTime.UtcNow.AddMinutes(-1) < testList1.ExpireAt &&
                        testList1.ExpireAt <= DateTime.UtcNow.AddDays(1));

            var testList2 = GetTestList(_database, list2.Item);

            Assert.Null(testList2.ExpireAt);
        }
        public virtual async Task <IActionResult> Update(string userId, [FromBody] ListDto list)
        {
            var repoList = await this._listRepository.GetAsync(list.Id);

            if (repoList == null)
            {
                return(this.NotFound());
            }

            // Only the list's user can update it
            if (repoList.UserId != userId)
            {
                return(this.Unauthorized());
            }

            var repoAlerts = await this._alertRepository.GetAllAsync(userId);

            var listAlertIds = list.Alerts.Select(x => x.Id).ToList();
            var listAlerts   = repoAlerts.Where(x => listAlertIds.Contains(x.Id)).ToList();

            repoList.Name   = list.Name;
            repoList.Alerts = listAlerts;

            repoList = await this._listRepository.UpdateAsync(repoList);

            var alertList = await this._alertListFactory.CreateAlertList(repoList);

            return(this.Ok(alertList));
        }
Exemple #8
0
        public ActionResult List(PagerRequest request, int?sort, SourceType?sourceType, int?sourceId)
        {
            int totalCount;
            var sortOrder = sort == null?ResourceSortOrder.CreateDate:(ResourceSortOrder)sort.Value;

            List <ResourceEntity> data;

            if (sourceType == null)
            {
                data = _resourceRepository.GetPagedList(request, out totalCount, sortOrder);
            }
            else
            {
                data = _resourceRepository.GetPagedList(request, out totalCount, sortOrder, sourceType, sourceId);
            }
            var vo = MappingManager.ResourceViewMapping(data);

            var v = new ResourceCollectionViewModel(request, totalCount)
            {
                Resources = vo.ToList()
            };

            var dto = new ListDto
            {
                ResourceCollectionViewModel = v,
                Sort       = sort,
                SourceId   = sourceId,
                SourceType = sourceType
            };

            return(View("List", dto));
        }
        public async Task <IActionResult> Put(Guid id, ListDto dto)
        {
            Guard.AgainstNull(dto, nameof(dto));

            if (dto.ID != id)
            {
                return(BadRequest());
            }

            var section = await Repository.GetList(id);

            if (section is null)
            {
                return(NotFound());
            }

            var updatedSection = section.With(
                title: dto.Title,
                order: dto.Order
                );

            await Repository.PersistList(updatedSection);

            return(Ok(dto));
        }
Exemple #10
0
        public ListDto AddList(AddListDto addListDto)
        {
            if (!_context.Boards.Any(x => x.Id == addListDto.BoardId))
            {
                return(null);
            }

            var list = new List
            {
                Name    = addListDto.Name,
                BoardId = addListDto.BoardId
            };

            _context.Lists.Add(list);
            _context.SaveChanges();

            var listDto = new ListDto
            {
                Id      = list.Id,
                BoardId = list.BoardId,
                Name    = list.Name
            };

            return(listDto);
        }
Exemple #11
0
        public ListDto <AdvertisementD> GetAdvertisementsPaged(int offset, int pageSize)
        {
            var list = new ListDto <AdvertisementD>();

            var sqlQueryItems =
                @"select man.ManufacturerName as CarManufacturer, carModel.CarModelName as CarModel, car.ProductionYear as ProductionYear,
			adv.Price as Price, car.VinCode as VinCode, gearBoxType.[Type] + ' ' + transmissionType.[Type] as Transmission,
			engineType.[Type] + ' ' + engine.[Value] + 'L. ' + CONVERT(VARCHAR(10), engine.HP) + 'hp' as Engine, 
			carUser.[Name] as UserName, carUser.Email as Email, carUser.Phone as Phone, photo.[PhotoName] as Photo
			from dbo.Car as car
				Left join  dbo.Advertisement as adv on car.AdvertisementId = adv.AdvertisementId
			left join dbo.Engine as engine on engine.EngineId = car.EngineId
			left join dbo.EngineType as engineType on engineType.EngineTypeId = engine.EngineTypeId
			left join dbo.Transmission as transmission on transmission.TransmissionId = car.TransmissionId
			left join dbo.GearBoxType as gearBoxType on gearBoxType.GearBoxTypeId = transmission.GearBoxTypeId
			left join dbo.TransmissionType as transmissionType on transmissionType.TransmissionTypeId = transmission.TransmissionTypeId
			left join dbo.CarModel as carModel on carModel.CarModelId = car.CarModelId
			left join dbo.Manufacturer as man on man.ManufacturerId = carModel.ManufacturerId
			left join dbo.[User] as carUser on carUser.UserId = adv.UserId
			left join dbo.[Photo] as photo on photo.AdvertisementId = adv.AdvertisementId
			ORDER BY CarManufacturer DESC
			OFFSET @offset ROWS
				FETCH NEXT @pageSize ROWS ONLY"                ;
            var sqlQueryCount = @"select COUNT(AdvertisementId) FROM dbo.Advertisement";

            using (IDbConnection con = new SqlConnection(ConnectionStringHelper.Get()))
            {
                list.Items = con.Query <AdvertisementD>(sqlQueryItems, new { offset = offset, pageSize = pageSize });
                list.Count = con.ExecuteScalar <int>(sqlQueryCount);
            }

            return(list);
        }
Exemple #12
0
    public bool Exists(SearchListDtoArg arg)
    {
        ListDto <SearchListDtoArg> args = new ListDto <SearchListDtoArg>();

        args.Add(arg);
        return(Exists(args.ToArray()));
    }
        public async Task <ListDto <UserDto> > GetUsersAsync(string pageToken = null, int pageSize = 50)
        {
            var list = new ListDto <UserDto>();

            list.PageSize = pageSize;
            //try
            //{
            var options = new FirebaseAdmin.Auth.ListUsersOptions
            {
                PageSize = 50
            };

            if (!string.IsNullOrEmpty(pageToken))
            {
                options.PageToken = pageToken;
            }

            var pagedEnumerable = FirebaseAuthAdmin.ListUsersAsync(options);
            var responses       = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();

            while (await responses.MoveNextAsync())
            {
                FirebaseAdmin.Auth.ExportedUserRecords response = responses.Current;
                list.PageToken = response.NextPageToken;
                foreach (FirebaseAdmin.Auth.ExportedUserRecord user in response.Users)
                {
                    var person = await GetPersonByUserIdAsync(user.Uid);

                    list.Items.Add
                    (
                        GetUserDto
                        (
                            person.Key,
                            new User
                            (
                                user.Uid,
                                person.Value?.FullName,
                                person.Value?.PhoneCountryCode,
                                person.Value?.PhoneNumber ?? 0,
                                person.Value?.CreatedAt ?? DateTime.MinValue,
                                person.Value?.Role ?? RoleOptions.Other,
                                person.Value?.IsEmailVerified ?? false,
                                person.Value?.Status ?? false,
                                user.Email,
                                person.Value?.RegistrationNumber,
                                null
                            )
                        )
                    );
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}

            list.Items = list.Items.OrderByDescending(x => x.CreatedAt).ToList();
            return(list);
        }
Exemple #14
0
    public int FindIndex(SearchListDtoArg arg)
    {
        ListDto <SearchListDtoArg> args = new ListDto <SearchListDtoArg>();

        args.Add(arg);
        return(FindIndex(args.ToArray()));
    }
Exemple #15
0
    public bool TrueForAll(SearchListDtoArg arg)
    {
        ListDto <SearchListDtoArg> args = new ListDto <SearchListDtoArg>();

        args.Add(arg);
        return(TrueForAll(args.ToArray()));
    }
Exemple #16
0
    public int FindLastIndex(SearchListDtoArg arg, int startIndex, int count)
    {
        ListDto <SearchListDtoArg> args = new ListDto <SearchListDtoArg>();

        args.Add(arg);
        return(FindLastIndex(args.ToArray(), startIndex, count));
    }
Exemple #17
0
    public T FindLast(SearchListDtoArg arg)
    {
        ListDto <SearchListDtoArg> args = new ListDto <SearchListDtoArg>();

        args.Add(arg);
        return(FindLast(args.ToArray()));
    }
Exemple #18
0
        public Task <IListDto <PurchaseOrderDto> > GetAllPurchaseOrderAsync(PurchaseOrderRequestAllDto request)
        {
            IListDto <PurchaseOrderDto> result = new ListDto <PurchaseOrderDto> {
                HasNext = false, Items = list
            };

            return(result.AsTask());
        }
        public async Task <IActionResult> Get(Guid _, Guid id)
        {
            var section = await Repository.GetList(id);

            return(section is null
                ? (IActionResult)NotFound()
                : Ok(ListDto.FromList(section)));
        }
Exemple #20
0
        public Task <IListDto <CustomerDto> > GetAllAsync(CustomerRequestAllDto request)
        {
            IListDto <CustomerDto> result = new ListDto <CustomerDto> {
                HasNext = false, Items = list
            };

            return(result.AsTask());
        }
Exemple #21
0
        public Task <IListDto <ProductDto> > GetAllProductAsync(ProductRequestAllDto request)
        {
            IListDto <ProductDto> result = new ListDto <ProductDto> {
                HasNext = false, Items = list
            };

            return(result.AsTask());
        }
        public async Task <ListDto <ProductDto> > GetProductsByCategoryAsync(string id, string path, int pageIndex, int pageSize)
        {
            var list = new ListDto <ProductDto>();

            try
            {
                list.PageIndex = pageIndex;
                list.PageSize  = pageSize;

                var products = await FirebaseClient
                               .Child(Table)
                               .OrderBy("CategoryId")
                               .EqualTo(id)
                               .OnceAsync <Product>();

                foreach (var p in products)
                {
                    list.Items.Add
                    (
                        GetProductDto
                        (
                            p.Key,
                            new Product
                            (
                                p.Object.Reference,
                                p.Object.Name,
                                p.Object.Description,
                                p.Object.Price,
                                p.Object.Currency,
                                p.Object.Pictures,
                                p.Object.CategoryId,
                                p.Object.UserId,
                                p.Object.CreatedAt,
                                p.Object.Status
                            ),
                            path,
                            await categoryService.GetCategoryAsync(p.Object.CategoryId),
                            await userService.GetUserAsync(p.Object.UserId)
                        )
                    );
                }
            }
            catch (Firebase.Database.FirebaseException ex)
            {
                if (ex.InnerException?.InnerException?.GetType() == typeof(SocketException))
                {
                    throw new HttpRequestException("Cannot join the server. Please check your internet connexion.");
                }
                throw ex;
            }
            catch (Exception)
            {
                return(null);
            }
            list.Items = list.Items.OrderByDescending(x => x.CreatedAt).ToList();
            return(list);
        }
Exemple #23
0
        public Task <IListDto <PurchaseOrderDto> > GetAllPurchaseOrdersAsync(PurchaseOrderRequestAllDto request)
        {
            var dtoList = _manager.List.Select(MapToPurchaseOrderDto);

            IListDto <PurchaseOrderDto> list = new ListDto <PurchaseOrderDto> {
                Items = dtoList.ToList(), HasNext = false
            };

            return(list.AsTask());
        }
Exemple #24
0
        private ListDto ConstructListDto(List list)
        {
            var listDto = new ListDto
            {
                Id      = list.Id,
                BoardId = list.BoardId,
                Name    = list.Name
            };

            return(listDto);
        }
Exemple #25
0
        public void InsertToList_AddsARecord_WithGivenValues()
        {
            UseConnection(database =>
            {
                Commit(database, x => x.InsertToList("my-key", "my-value"));

                ListDto record = database.JobGraph.OfType <ListDto>().Find(new BsonDocument()).ToList().Single();
                Assert.Equal("my-key", record.Item);
                Assert.Equal("my-value", record.Value);
            });
        }
Exemple #26
0
        public async Task <IActionResult> GetAll([FromQuery] CustomerRequestAllDto requestAll)
        {
            if (requestAll == null)
            {
                return(BadRequest(ListDto <CustomerDto> .Empty()));
            }

            var response = await _customerDomainService.GetAllAsync <CustomerDto>(requestAll,
                                                                                  (c) => requestAll.Name.IsNullOrEmpty() || c.Name.Contains(requestAll.Name));

            return(CreateResponseOnGetAll(response, _name));
        }
Exemple #27
0
        public void InsertToList_AddsARecord_WithGivenValues()
        {
            UseConnection(database =>
            {
                Commit(database, x => x.InsertToList("my-key", "my-value"));

                ListDto record = AsyncHelper.RunSync(() => database.List.Find(new BsonDocument()).ToListAsync()).Single();

                Assert.Equal("my-key", record.Key);
                Assert.Equal("my-value", record.Value);
            });
        }
        public async Task <IActionResult> CreateList([FromBody] ListDto listName)
        {
            var newList = new List();

            newList.ListName = listName.ListName;

            _context.Lists.Add(newList);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLists", new { id = newList.Id }, newList));
        }
Exemple #29
0
        public async Task <IActionResult> GetAll([FromQuery] ProductRequestAllDto requestAll)
        {
            if (requestAll == null)
            {
                return(BadRequest(ListDto <ProductDto> .Empty()));
            }

            var response = await _productDomainService.GetAllAsync <ProductDto>(requestAll,
                                                                                (p) => requestAll.Description.IsNullOrEmpty() || p.Description.Contains(requestAll.Description));

            return(CreateResponseOnGetAll(response, name));
        }
Exemple #30
0
        public UserMainViewModel(UserMain userView, tblUser userLogedIn)
        {
            view        = userView;
            User        = userLogedIn;
            postService = new PostService();
            userService = new UserService();
            PostList    = postService.GetPosts();
            ListDto     = ConvertListToDtoList(PostList);

            FriendList   = userService.GetFriends(User);
            CheckList    = FriendList.Select(item => item.UserID).ToList();
            SelectedPost = ListDto.FirstOrDefault();
        }
Exemple #31
0
        public ActionResult MyIndex(ListRequest request, PagerRequest pagerRequest)
        {
            var linq = _productRepository.Get(Filter(new ProductFilter
            {
                DataStatus = DataStatus.Normal,
                UserId = request.CustomerId
            }));

            var totalCount = linq.Count();

            var result = pagerRequest.PageIndex == 1 ? linq.Take(pagerRequest.PageSize) : linq.Skip((pagerRequest.PageSize - 1) * pagerRequest.PageSize).Take(pagerRequest.PageSize);

            var dto = new ListDto(pagerRequest, totalCount)
            {
                Datas = result.ToList()
            };

            return View(dto);
        }
Exemple #32
0
        public ActionResult List(ListRequest request, PagerRequest pagerRequest)
        {
            var linq = _productRepository.Get(Filter(new ProductFilter
                {
                    DataStatus = DataStatus.Normal,
                    UserId = request.CustomerId,
                    IsShare = true
                })).OrderByDescending(v=>v.UpdatedDate);

            var totalCount = linq.Count();

            var result = pagerRequest.PageIndex == 1 ? linq.Take(pagerRequest.PageSize) : linq.Skip((pagerRequest.PageIndex - 1) * pagerRequest.PageSize).Take(pagerRequest.PageSize);

            var dto = new ListDto(pagerRequest, totalCount)
                {
                    Datas = result.ToList()
                };

            return View("List", dto);
        }