private async void btnSearch_Click(object sender, EventArgs e)
        {
            var request = new ListingSearchRequest
            {
                Approved = true,
                City     = txtCity.Text,
            };

            if (IsStartDateNull)
            {
                request.StartDate = null;
            }
            else
            {
                request.StartDate = dtpStart.Value;
            }

            if (IsEndDateNull)
            {
                request.EndDate = null;
            }
            else
            {
                request.EndDate = dtpEnd.Value;
            }

            var result = await _listingService.Get <List <Listing> >(request);

            dgvListings.AutoGenerateColumns = false;
            dgvListings.DataSource          = result;
        }
        private async void ucListings_Load(object sender, EventArgs e)
        {
            var request = new ListingSearchRequest {
                Approved = true
            };

            var result = await _listingService.Get <List <Listing> >(request);

            dgvListings.AutoGenerateColumns = false;
            dgvListings.DataSource          = result;
        }
예제 #3
0
        private async void ucHighestRatedListings_Load(object sender, EventArgs e)
        {
            var request = new ListingSearchRequest {
                Approved = true
            };

            var result = await _listingService.Get <List <Listing> >(request);

            result = result.OrderByDescending(x => x.AverageRating).ToList();
            dgvListings.AutoGenerateColumns = false;
            dgvListings.DataSource          = result;
        }
예제 #4
0
        private async void btnSearch_Click(object sender, EventArgs e)
        {
            var request = new ListingSearchRequest
            {
                Approved = true,
                City     = txtCity.Text,
            };

            var result = await _listingService.Get <List <Listing> >(request);

            dgvListings.AutoGenerateColumns = false;
            dgvListings.DataSource          = result;
        }
예제 #5
0
        private async void ucApproveListings_Load(object sender, EventArgs e)
        {
            var request = new ListingSearchRequest {
                Approved = false
            };

            var result = await _listingService.Get <List <Listing> >(request);

            dgvListings.AutoGenerateColumns = false;
            dgvListings.DataSource          = result;

            var count = result.Count;

            txtCount.Text = count.ToString();
        }
예제 #6
0
        public List <Model.Listing> Get(ListingSearchRequest request)
        {
            var query = _context.Listing.Include(x => x.Territory).Include(x => x.User).AsQueryable();

            if (request != null)
            {
                query = query.Where(x => x.Approved == request.Approved);
                if (!string.IsNullOrWhiteSpace(request.City))
                {
                    query = query.Where(x => x.City.StartsWith(request.City));
                }
                if (request.StartDate != null)
                {
                    query = query.Where(x => x.DateApproved > request.StartDate);
                }
                if (request.EndDate != null)
                {
                    query = query.Where(x => x.DateApproved < request.EndDate);
                }
            }
            var list = query.Select(x => new Model.Listing
            {
                Address            = x.Address,
                AreaDescription    = x.AreaDescription,
                Bathrooms          = x.Bathrooms,
                Beds               = x.Beds,
                City               = x.City,
                DateCreated        = x.DateCreated,
                DateApproved       = x.DateApproved,
                ListingDescription = x.ListingDescription,
                Name               = x.Name,
                Persons            = x.Persons,
                TerritoryName      = x.Territory.Name,
                UserName           = x.User.FirstName + " " + x.User.LastName,
                ListingId          = x.ListingId,
                AverageRating      = _context.Rating.Where(y => y.ListingId == x.ListingId).Average(y => y.RatingValue)
            }).ToList();

            return(list);
        }
예제 #7
0
        private async void btnPDF_Click(object sender, EventArgs e)
        {
            var request = new ListingSearchRequest
            {
                Approved = true,
                City     = txtCity.Text,
            };

            if (IsStartDateNull)
            {
                request.StartDate = null;
            }
            else
            {
                request.StartDate = dtpStart.Value;
            }

            if (IsEndDateNull)
            {
                request.EndDate = null;
            }
            else
            {
                request.EndDate = dtpEnd.Value;
            }

            var tableData = await _listingService.Get <List <Listing> >(request);

            var month    = DateTime.Now.ToString("MM");
            var year     = DateTime.Now.ToString("yyyy");
            var fileName = "detaljiOglasa_" + month + "_" + year + ".pdf";
            var path     = "..\\..\\Data\\Reports\\izvjestaj_" + fileName;

            PdfWriter   writer   = new PdfWriter(path);
            PdfDocument pdf      = new PdfDocument(writer);
            Document    document = new Document(pdf);
            Paragraph   header   = new Paragraph("Izvještaj za mjesec: " + month + ". " + year + ". godine")
                                   .SetTextAlignment(TextAlignment.CENTER)
                                   .SetFontSize(20);

            document.Add(header);
            document.Add(new Paragraph(new Text("\n")));
            document.Add(new Paragraph("Broj aktivnih oglasa po gradovima"))
            .SetTextAlignment(TextAlignment.CENTER)
            .SetFontSize(15);


            float[] columnWidths = { 1, 2, 2, 2, 2, 2 };
            Table   table        = new Table(UnitValue.CreatePercentArray(columnWidths));

            table.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);

            Cell[] headerFooter = new Cell[] {
                new Cell().SetTextAlignment(TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("RB.")),
                new Cell().SetTextAlignment(TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Naziv")),
                new Cell().SetTextAlignment(TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Lokacija")),
                new Cell().SetTextAlignment(TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Kanton")),
                new Cell().SetTextAlignment(TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Korisnik")),
                new Cell().SetTextAlignment(TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Datum objave"))
            };

            foreach (Cell hfCell in headerFooter)
            {
                table.AddHeaderCell(hfCell);
            }

            int counter = 1;

            tableData = tableData.ToList();

            if (tableData != null)
            {
                foreach (var row in tableData)
                {
                    table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).Add(new Paragraph(counter++.ToString())));
                    table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).Add(new Paragraph(row.Name)));
                    table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).Add(new Paragraph(row.City)));
                    table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).Add(new Paragraph(row.TerritoryName)));
                    table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).Add(new Paragraph(row.UserName)));
                    table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).Add(new Paragraph(row.DateApproved.ToString("dd/MM/yyyy"))));
                }
            }
            document.Add(table);

            document.Close();
            MessageBox.Show("Izvjestaj uspjesno kreiran!");
        }
예제 #8
0
 public ActionResult <List <Model.Listing> > Get([FromQuery] ListingSearchRequest request)
 {
     return(_service.Get(request));
 }