Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RSN-37] - Created services #42

Merged
merged 65 commits into from
Jun 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ea37bc7
Created CRUD services for Parameter, Status, Tag and C&U for Event
bilimig Mar 30, 2024
bbe1798
created CRUD Image, Interest, Event and Parameter Services
bilimig Mar 30, 2024
9b0381f
changed delete services to void isnted of bool
bilimig Apr 2, 2024
e101e09
Fixed GetByFilter service in Event, Image, Intrest, Parameter, Status…
bilimig Apr 3, 2024
690a93c
little changes
bilimig Apr 13, 2024
4332abe
fixing build issue and changing list to ienumerable
bilimig Apr 13, 2024
a7495d1
Fixing EventServices and standardizing syntax issues
bilimig Apr 14, 2024
6185066
created test for interest status parameter and tag
bilimig Apr 17, 2024
db6a70f
Created ImageServicesTests
bilimig Apr 18, 2024
ce92d22
Updated Parameter, Tag, Status services
bilimig May 1, 2024
63f3d77
fixed bug in imageservicetest
bilimig May 2, 2024
e760dbb
one more fix
bilimig May 2, 2024
196ef61
Updated services and tests
bilimig May 6, 2024
7784b40
Updated services
bilimig May 7, 2024
ae26b70
Updates after scafoled nr 1
bilimig May 27, 2024
fc48408
Updated services
bilimig May 30, 2024
ad78d8b
Updated EventService
bilimig May 30, 2024
f19e208
working event services
bilimig Jun 6, 2024
2428425
created mappers and small fixes
bilimig Jun 9, 2024
095dd7d
finished mappers
bilimig Jun 9, 2024
028d043
Added exceptions in services
mkoper02 Jun 9, 2024
687a5bd
fixed mappers according to our convension
bilimig Jun 9, 2024
17ef41a
Changed exceptions directory location
mkoper02 Jun 9, 2024
5cc818a
fixed build error
bilimig Jun 9, 2024
3021123
Exceptions changes
mkoper02 Jun 9, 2024
bf25afd
Unit tests fix
mkoper02 Jun 9, 2024
a52a1d3
updated services
bilimig Jun 10, 2024
c64189f
Slug creating method updated
bilimig Jun 10, 2024
342ab16
Update ImageService.cs
bilimig Jun 10, 2024
68f4c17
Update ImageService.cs
bilimig Jun 10, 2024
faa050a
updated image services and tests also updated slug method for event s…
bilimig Jun 10, 2024
7bda1bf
event service delete method updated
bilimig Jun 10, 2024
0f2a8c0
refactor and fixes
bilimig Jun 10, 2024
59b3bea
refactor
bilimig Jun 10, 2024
2a1b4a7
Update EventService.cs
bilimig Jun 10, 2024
8385ed8
last refactor
bilimig Jun 10, 2024
90305e2
removing spaces
bilimig Jun 10, 2024
3f10272
added geteventbyslug method to eventservice
bilimig Jun 10, 2024
a941d1d
Update ImageService.cs
bilimig Jun 10, 2024
9df5dcb
refactor
bilimig Jun 10, 2024
fc7e7c7
changed list to Enumerable
bilimig Jun 10, 2024
55bc25c
changed list to enumerable
bilimig Jun 10, 2024
1e4316a
folder refactor
bilimig Jun 10, 2024
dc4ffa9
updated services
bilimig Jun 11, 2024
12bbc02
Update EventService.cs
bilimig Jun 11, 2024
6886e31
changes
bilimig Jun 12, 2024
c343f40
Update EventServicesTest.cs
bilimig Jun 12, 2024
55b9e7d
updates
bilimig Jun 12, 2024
912344c
Update EventService.cs
bilimig Jun 12, 2024
e747b3d
Update EventService.cs
bilimig Jun 12, 2024
a79b31f
Update ImageService.cs
bilimig Jun 12, 2024
2f4128c
Updates
bilimig Jun 12, 2024
450849b
Update EventMapper.cs
bilimig Jun 12, 2024
f51885e
changes
bilimig Jun 12, 2024
631d8b7
Update ImageServiceTests.cs
bilimig Jun 12, 2024
9bb1ca6
changes
bilimig Jun 12, 2024
3c01c4f
Formating
bilimig Jun 12, 2024
ecbdf3f
Update EventService.cs
bilimig Jun 13, 2024
e74a0d2
Update EventService.cs
bilimig Jun 13, 2024
08462e1
changes
bilimig Jun 13, 2024
4223069
Created AddEventComment method
bilimig Jun 14, 2024
54001a6
Update EventService.cs
bilimig Jun 14, 2024
3a3274f
fixed updating and creating event
bilimig Jun 15, 2024
fc3c82f
Update EventService.cs
bilimig Jun 17, 2024
f5dace1
changed create slug and text for event
bilimig Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions Server/ReasnAPI/ReasnAPI/Services/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public EventDto CreateEvent(EventDto eventDto)
var newEvent = eventDto.ToEntity();
newEvent.CreatedAt = createdTime;
newEvent.UpdatedAt = createdTime;
newEvent.Slug = CreateSlug(eventDto, createdTime);
newEvent.Slug = CreateSlug(eventDto);

context.Events.Add(newEvent);

Expand Down Expand Up @@ -257,24 +257,25 @@ public IEnumerable<EventDto> GetUserEvents(string username)
return userEvents.ToDtoList().AsEnumerable();
}

private string CreateSlug(EventDto eventDto, DateTime createdTime)
private string CreateSlug(EventDto eventDto)
{
var slug = eventDto.Name.ToLower();
slug = slug.Trim();
slug = Regex.Replace(slug, @"\s+", " ");
slug = Regex.Replace(slug, " ", "-");
slug = Regex.Replace(slug, @"[^a-z0-9-]", "");
slug = Regex.Replace(slug, "-+", "-");
var baseSlug = eventDto.Name.ToLower();
baseSlug = baseSlug.Trim();
baseSlug = Regex.Replace(baseSlug, @"\s+", " ");
baseSlug = Regex.Replace(baseSlug, " ", "-");
baseSlug = Regex.Replace(baseSlug, @"[^a-z0-9-]", "");
baseSlug = Regex.Replace(baseSlug, "-+", "-");

var timestamp = createdTime.Ticks.ToString();
var maxSlugLength = 128 - timestamp.Length - 1; // -1 for the dash between slug and timestamp
var slug = baseSlug;
var counter = 1;

if (slug.Length > maxSlugLength)
while (context.Events.Any(e => e.Slug == slug))
{
slug = slug.Substring(0, maxSlugLength);
slug = $"{baseSlug}-{counter}";
counter++;
}

return $"{slug}-{timestamp}";
return slug;
}
bilimig marked this conversation as resolved.
Show resolved Hide resolved

}
Loading