Skip to content

Instantly share code, notes, and snippets.

@laribee
Last active September 3, 2020 19:09
Show Gist options
  • Save laribee/0dbf2167fe63cf15ca2befb2764d1021 to your computer and use it in GitHub Desktop.
Save laribee/0dbf2167fe63cf15ca2befb2764d1021 to your computer and use it in GitHub Desktop.
[HttpPost]
public IActionResult Post(CreateEventDto m)
{
var organizer = new OrganizersService().GetOrganizerDetails( new AuthenticationService().GetCurrentUser());
if (m.Description == null) throw new ArgumentException();
if (m.Title == null) throw new ArgumentException();
if (m.Starts > m.Ends)
{
throw new ArgumentException();
}
if (m.Status == "Published")
{
if (m.Starts < DateTime.Now)
{
throw new ArgumentException();
}
if (m.Capacity <= 0) throw new ArgumentException();
if (m.Tickets.Capacity != m.Capacity) throw new ArgumentException();
decimal pr = m.Tickets.Capacity * m.Tickets.Cost;
m.PotentialRevenue = pr;
new EventListingManager().Notify(m);
}
new DataAccessLayer().Save(m);
return Ok();
}
private decimal CalculatePotentialRevenue(CreateEventDto createEventDto)
{
return (createEventDto.Tickets.Capacity * createEventDto.Tickets.Cost);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment