Skip to content

Commit

Permalink
Slug creating method updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bilimig committed Jun 10, 2024
1 parent 6b03b48 commit c2a8322
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Server/ReasnAPI/ReasnAPI/Services/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ public EventDto CreateEvent(EventDto eventDto)
{
using (var scope = new TransactionScope())
{
eventDto.Slug = CreateSlug(eventDto);
var nowTime = DateTime.UtcNow;

var createdTime = DateTime.UtcNow;
var newEvent = eventDto.ToEntity();
newEvent.CreatedAt = nowTime;
newEvent.UpdatedAt = nowTime;
newEvent.Slug = eventDto.Slug;
newEvent.CreatedAt = createdTime;
newEvent.UpdatedAt = createdTime;
newEvent.Slug = CreateSlug(eventDto, createdTime);


context.Events.Add(newEvent);
context.SaveChanges();
Expand Down Expand Up @@ -230,10 +231,11 @@ public IEnumerable<EventDto> GetAllEvents()
return eventDtos;
}

private string CreateSlug(EventDto eventDto)
private string CreateSlug(EventDto eventDto, DateTime createdTime)
{
var slug = eventDto.Name.ToLower().Replace(" ", "-");
return slug;
var timestamp = createdTime.Ticks;
return $"{slug}-{timestamp}";
}

}

0 comments on commit c2a8322

Please sign in to comment.