public int CreateEvent(CreateEventRequest request) { var errors = _eventRequestsValidator.ValidateCreateEventRequest(request); if (errors.Count > 0) { throw new ValidationException(); } var endDate = _eventDateCalculator.CalculateEventEndDate(request.StartDate, request.EndDate, request.RecurrenceType, request.Interval, request.Duration, request.Occurences, request.FrequencyType, request.Days); return(_eventRepository.AddEvent(new CalendarEvent { Duration = request.Duration, EndDate = endDate, IsAllDay = request.IsAllDay, Name = request.Name, StartDate = request.StartDate, Days = request.Days, FrequencyType = request.FrequencyType, Interval = request.Interval, RecurrenceType = request.RecurrenceType, Occurences = request.Occurences, })); }
public List <string> ValidateCreateEventRequest(CreateEventRequest createEventRequest) { var errors = new List <string>(); if (string.IsNullOrEmpty(createEventRequest.Name)) { errors.Add("Nazwa wydarzenia nie może być pusta"); } return(errors); }