Browse Source

Edit home page

pull/41/head
Berkan Sasmaz 6 years ago
parent
commit
85bee2c264
  1. 4
      src/EventHub.Application.Contracts/Events/EventInListDto.cs
  2. 2
      src/EventHub.Application.Contracts/Events/EventListFilterDto.cs
  3. 11
      src/EventHub.Application/Events/EventAppService.cs
  4. 34
      src/EventHub.Domain/Events/Event.cs
  5. 34
      src/EventHub.Domain/Events/EventManager.cs
  6. 2639
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210428213802_Added_CountryName_To_Event.Designer.cs
  7. 23
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210428213802_Added_CountryName_To_Event.cs
  8. 5271
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs
  9. 2
      src/EventHub.Web.Theme/Themes/EventHub/Components/MainNavbar/Default.cshtml
  10. 8
      src/EventHub.Web.Theme/wwwroot/themes/eventhub/owl-edit.css
  11. 10
      src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css
  12. 6
      src/EventHub.Web/Pages/Events/EventDateHelper.cs
  13. 149
      src/EventHub.Web/Pages/Index.cshtml
  14. 23
      src/EventHub.Web/Pages/Index.cshtml.cs
  15. 1
      src/EventHub.Web/Pages/Index.js

4
src/EventHub.Application.Contracts/Events/EventInListDto.cs

@ -20,6 +20,10 @@ namespace EventHub.Events
public byte[] CoverImageContent { get; set; }
public bool IsOnline { get; set; }
public string Country { get; set; }
public string City { get; set; }
public int? Capacity { get; set; }

2
src/EventHub.Application.Contracts/Events/EventListFilterDto.cs

@ -11,6 +11,8 @@ namespace EventHub.Events
public Guid? OrganizationId { get; set; }
public bool? IsOnline { get; set; }
public EventListFilterDto()
{
MaxResultCount = 20;

11
src/EventHub.Application/Events/EventAppService.cs

@ -65,7 +65,7 @@ namespace EventHub.Events
input.Description
);
@event.SetLocation(input.IsOnline, input.OnlineLink, input.CountryId, input.City);
await _eventManager.SetLocationAsync(@event, input.IsOnline, input.OnlineLink, input.CountryId, input.City);
@event.Language = input.Language;
await _eventManager.SetCapacityAsync(@event, input.Capacity);
@ -103,6 +103,11 @@ namespace EventHub.Events
{
query = query.Where(i => i.@event.OrganizationId == input.OrganizationId.Value);
}
if (input.IsOnline.HasValue)
{
query = query.Where(i => i.@event.IsOnline == input.IsOnline);
}
var totalCount = await AsyncExecuter.CountAsync(query);
@ -127,6 +132,7 @@ namespace EventHub.Events
dto.OrganizationName = i.organization.Name;
dto.OrganizationDisplayName = i.organization.DisplayName;
dto.IsLiveNow = now.IsBetween(i.@event.StartTime, i.@event.EndTime);
dto.Country = i.@event.CountryName;
return dto;
}
).ToList();
@ -177,7 +183,6 @@ namespace EventHub.Events
return dto;
}
[Authorize]
public async Task<List<CountryLookupDto>> GetCountriesLookupAsync()
{
var countriesQueryable = await _countriesRepository.GetQueryableAsync();
@ -213,7 +218,7 @@ namespace EventHub.Events
);
}
@event.SetLocation(input.IsOnline, input.OnlineLink, input.CountryId, input.City);
await _eventManager.SetLocationAsync(@event, input.IsOnline, input.OnlineLink, input.CountryId, input.City);
@event.SetTitle(input.Title);
@event.SetDescription(input.Description);
@event.Language = input.Language;

34
src/EventHub.Domain/Events/Event.cs

@ -20,13 +20,15 @@ namespace EventHub.Events
public string Description { get; private set; }
public bool IsOnline { get; private set; }
public bool IsOnline { get; internal set; }
public string OnlineLink { get; private set; }
public string OnlineLink { get; internal set; }
public Guid? CountryId { get; private set; }
public Guid? CountryId { get; internal set; }
public string City { get; private set; }
public string CountryName { get; internal set; }
public string City { get; internal set; }
public string Language { get; set; }
@ -79,30 +81,6 @@ namespace EventHub.Events
return SetTimeInternal(startTime, endTime);
}
public Event SetLocation(
bool isOnline,
string onlineLink,
Guid? countryId,
string city)
{
IsOnline = isOnline;
if (IsOnline)
{
OnlineLink = onlineLink;
CountryId = null;
City = null;
}
else
{
OnlineLink = null;
CountryId = countryId;
City = city;
}
return this;
}
private Event SetTimeInternal(DateTime startTime, DateTime endTime)
{
if (startTime > endTime)

34
src/EventHub.Domain/Events/EventManager.cs

@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using EventHub.Countries;
using EventHub.Events.Registrations;
using EventHub.Organizations;
using Volo.Abp;
@ -13,13 +14,16 @@ namespace EventHub.Events
{
private readonly EventUrlCodeGenerator _eventUrlCodeGenerator;
private readonly IRepository<EventRegistration, Guid> _eventRegistrationRepository;
private readonly IRepository<Country, Guid> _countriesRepository;
public EventManager(
EventUrlCodeGenerator eventUrlCodeGenerator,
IRepository<EventRegistration, Guid> eventRegistrationRepository)
IRepository<EventRegistration, Guid> eventRegistrationRepository,
IRepository<Country, Guid> countriesRepository)
{
_eventUrlCodeGenerator = eventUrlCodeGenerator;
_eventRegistrationRepository = eventRegistrationRepository;
_countriesRepository = countriesRepository;
}
public async Task<Event> CreateAsync(
@ -55,5 +59,33 @@ namespace EventHub.Events
@event.Capacity = capacity;
}
public async Task SetLocationAsync(
Event @event,
bool isOnline,
string onlineLink,
Guid? countryId,
string city)
{
@event.IsOnline = isOnline;
if (@event.IsOnline)
{
@event.OnlineLink = onlineLink;
@event.CountryId = null;
@event.CountryName = null;
@event.City = null;
}
else
{
Check.NotNull(countryId, nameof(countryId));
Check.NotNull(city, nameof(city));
@event.OnlineLink = null;
@event.CountryId = countryId;
@event.CountryName = (await _countriesRepository.GetAsync(@event.CountryId!.Value)).Name;
@event.City = city;
}
}
}
}

2639
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210428213802_Added_CountryName_To_Event.Designer.cs

File diff suppressed because it is too large

23
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210428213802_Added_CountryName_To_Event.cs

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace EventHub.Migrations
{
public partial class Added_CountryName_To_Event : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "CountryName",
table: "EhEvents",
type: "text",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CountryName",
table: "EhEvents");
}
}
}

5271
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs

File diff suppressed because it is too large

2
src/EventHub.Web.Theme/Themes/EventHub/Components/MainNavbar/Default.cshtml

@ -19,8 +19,6 @@
<li class="nav-item @(GetPageActiveClassOrEmpty(ViewContext, "/Index"))">
<a class="nav-link" href="@Url.Page("/Index")">
Home
@* ToDo: Underline? *@
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item @(GetPageActiveClassOrEmpty(ViewContext, "/Events/Index"))">

8
src/EventHub.Web.Theme/wwwroot/themes/eventhub/owl-edit.css

@ -44,7 +44,7 @@
height: 40px;
top:0;
left: 0;
background-image: url(assets/slider-right.svg);
background-image: url(../../../../assets/slider-right.svg);
background-position: center;
background-repeat: no-repeat;
}
@ -56,7 +56,7 @@
height: 40px;
top:0;
left: 0;
background-image: url(assets/slider-left.svg);
background-image: url(../../../../assets/slider-left.svg);
background-position: center;
background-repeat: no-repeat;
}
@ -79,7 +79,7 @@
height: 15px;
top:0;
left: 0;
background-image: url(assets/owl-2-right.svg);
background-image: url(../../../../assets/owl-2-right.svg);
background-position: center;
background-repeat: no-repeat;
}
@ -91,7 +91,7 @@
height: 15px;
top:0;
left: 0;
background-image: url(assets/owl-2-left.svg);
background-image: url(../../../../assets/owl-2-left.svg);
background-position: center;
background-repeat: no-repeat;
}

10
src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css

@ -85,7 +85,7 @@ p {
transition: color 0.3s ease;
}
.active .nav-link {
background-image: url(assets/underline.svg);
background-image: url(../../../../assets/underline.svg);
background-repeat: no-repeat;
background-size: inherit;
background-position: center 28px;
@ -308,7 +308,7 @@ p {
.form-select{
background-color: #EFEFF4;
border: 1px solid #EFEFF4;
background-image: url("assets/select-arrow.svg");
background-image: url("../../../../assets/select-arrow.svg");
background-position: right 20px center;
background-repeat: no-repeat;
background-size: 10px;
@ -341,7 +341,7 @@ p {
border: 0;
width: 6px;
height: 4px;
background: url(assets/dropdown-arrow.svg) center center no-repeat;
background: url(../../../../assets/dropdown-arrow.svg) center center no-repeat;
background-size: contain;
top: 2px;
position: relative;
@ -456,13 +456,13 @@ footer .footer-links a:hover{
.inner-banner {
text-align: center;
height: 250px;
background: url(assets/inner-banner.png) center center no-repeat;
background: url(../../../../assets/inner-banner.png) center center no-repeat;
background-size: cover;
margin-bottom: 30px;
}
.inner-banner.inner-banner-2 {
background-image: url(assets/inner-banner-2.png);
background-image: url(../../../../assets/inner-banner-2.png);
}
.inner-banner h1 {

6
src/EventHub.Web/Pages/Events/EventDateHelper.cs

@ -32,7 +32,11 @@ namespace EventHub.Web.Pages.Events
}
else
{
return "???";
var sb = new StringBuilder();
sb.Append(eventItem.City);
sb.Append('/');
sb.Append(eventItem.Country);
return sb.ToString();
}
}
}

149
src/EventHub.Web/Pages/Index.cshtml

@ -1,5 +1,6 @@
@page
@model EventHub.Web.Pages.IndexModel
@using System.Globalization
@using Microsoft.AspNetCore.Mvc.Localization
@using EventHub.Localization
@using EventHub.Web.Pages.Events
@ -48,9 +49,10 @@
<div class="col-md mb-3 mb-md-0">
<select class="form-select" aria-label="Default select example">
<option selected>Looking for</option>
<option value="1">Lorem</option>
<option value="2">Ipsum</option>
<option value="3">Dolor</option>
@foreach (var country in Model.Countries)
{
<option value=@country.Id>@country.Name</option>
}
</select>
</div>
<div class="col-md mb-3 mb-md-0">
@ -99,13 +101,13 @@
<div class="card-body">
<div class="event-container">
<div class="form-row">
<div class="col-2">
<div class="col-3">
<div class="event-date text-center">
<small>@eventItem.StartTime.ToString("MMM")</small>
<span>@eventItem.StartTime.Day</span>
</div>
</div>
<div class="col-10">
<div class="col-9">
<div class="event-info">
<h5>@eventItem.Title</h5>
<small>@eventItem.StartTime.ToString("hh:mm") | @EventDateHelper.GetLocationInfo(eventItem)</small>
@ -137,126 +139,49 @@
<h2 class="mb-4">Online Events</h2>
<div class="owl-carousel owl-theme">
<div class="item">
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>Bitcoin</h5>
<small>May 6, 2021 Monday | 7 pm - 9 pm | Online</small>
<p>Some quick example text to build on the card title and make up the bud titlcard title and make up the bud titlcard title and make up the bud title and make up e card's content.</p>
</div>
<a href="#" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
</div>
</div>
</div>
</div>
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>Bitcoin</h5>
<small>May 6, 2021 Monday | 7 pm - 9 pm | Online</small>
<p>Some quick example text to build on the card title and make up the bud titlcard title and make up the bud titlcard title and make up the bud title and make up e card's content.</p>
</div>
<a href="#" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>Bitcoin</h5>
<small>May 6, 2021 Monday | 7 pm - 9 pm | Online</small>
<p>Some quick example text to build on the card title and make up the bud titlcard title and make up the bud titlcard title and make up the bud title and make up e card's content.</p>
</div>
<a href="#" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
@for (var i = 0; i < Model.OnlineEvents.Count; i+=2)
{
<div class="item">
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
</div>
</div>
</div>
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>Bitcoin</h5>
<small>May 6, 2021 Monday | 7 pm - 9 pm | Online</small>
<p>Some quick example text to build on the card title and make up the bud titlcard title and make up the bud titlcard title and make up the bud title and make up e card's content.</p>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>@Model.OnlineEvents[i].Title</h5>
<small>@Model.OnlineEvents[i].StartTime.ToString("MMMM dd, yyyy dddd") | @Model.OnlineEvents[i].StartTime.ToString("hh tt", CultureInfo.InvariantCulture) - @Model.OnlineEvents[i].EndTime.ToString("hh tt", CultureInfo.InvariantCulture) | Online</small>
<p>@Model.OnlineEvents[i].Description</p>
</div>
<a href="@Url.Page("/Events/Detail", new {url = @Model.OnlineEvents[i].Url})" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
<a href="#" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>Bitcoin</h5>
<small>May 6, 2021 Monday | 7 pm - 9 pm | Online</small>
<p>Some quick example text to build on the card title and make up the bud titlcard title and make up the bud titlcard title and make up the bud title and make up e card's content.</p>
</div>
<a href="#" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
</div>
</div>
</div>
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-5">
<img src="/assets/card-left-image.png" class="card-img-left">
</div>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>Bitcoin</h5>
<small>May 7, 2021 Monday | 7 pm - 9 pm | Online</small>
<p>Some quick example text to build on the card title and make up the bud titlcard title and make up the bud titlcard title and make up the bud title and make up e card's content.</p>
<div class="col-md-7">
<div class="card-body">
<div class="event-container online-event">
<div class="event-info">
<h5>@Model.OnlineEvents[i + 1].Title</h5>
<small>@Model.OnlineEvents[i + 1].StartTime.ToString("MMMM dd, yyyy dddd") | @Model.OnlineEvents[i + 1].StartTime.ToString("hh tt", CultureInfo.InvariantCulture) - @Model.OnlineEvents[i + 1].EndTime.ToString("hh tt", CultureInfo.InvariantCulture) | Online</small>
<p>@Model.OnlineEvents[i + 1].Description</p>
</div>
<a href="@Url.Page("/Events/Detail", new {url = @Model.OnlineEvents[i + 1].Url})" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
<a href="#" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
</div>
</div>
</div>
</div>
</div>
</div>
}
</div>
</div>
</div>

23
src/EventHub.Web/Pages/Index.cshtml.cs

@ -1,13 +1,21 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using EventHub.Events;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc.Rendering;
using NUglify.Helpers;
namespace EventHub.Web.Pages
{
public class IndexModel : EventHubPageModel
{
public IReadOnlyList<EventInListDto> Events { get; private set; }
public IReadOnlyList<EventInListDto> OnlineEvents { get; private set; }
public List<CountryLookupDto> Countries { get; private set; }
private readonly IEventAppService _eventAppService;
@ -18,14 +26,23 @@ namespace EventHub.Web.Pages
public async Task OnGetAsync()
{
var result = await _eventAppService.GetListAsync(
Events = (await _eventAppService.GetListAsync(
new EventListFilterDto
{
MinDate = Clock.Now
}
);
)).Items;
Events = result.Items;
OnlineEvents = (await _eventAppService.GetListAsync(
new EventListFilterDto
{
MinDate = Clock.Now,
IsOnline = true,
MaxResultCount = 8
}
)).Items;
Countries = await _eventAppService.GetCountriesLookupAsync();
}
public async Task OnPostLoginAsync()

1
src/EventHub.Web/Pages/Index.js

@ -15,6 +15,7 @@
margin:30,
padding:0,
nav:true,
slideBy: 2,
responsive:{
0:{
items:1,

Loading…
Cancel
Save