public static ServiceResultLine ToAggregate(this Service service, ServiceOccurrence serviceOccurrence, DateTime dateTime) { if (service == null) { throw new ArgumentNullException(nameof(service)); } if (serviceOccurrence == null) { throw new ArgumentNullException(nameof(serviceOccurrence)); } IEnumerable <string> images = null; if (service.Images != null) { images = service.Images.Select(i => i.PartialPath); } IEnumerable <string> tags = null; if (service.Tags != null) { tags = service.Tags.Select(t => t.TagName); } return(new ServiceResultLine { Description = service.Description, Id = service.Id, Name = service.Name, PartialImagesUrl = images, Price = service.Price, ShopId = service.ShopId, Tags = tags, AverageScore = service.AverageScore, TotalScore = service.TotalScore, StartDateTime = dateTime.Add(serviceOccurrence.StartTime), EndDateTime = dateTime.Add(serviceOccurrence.EndTime) }); }
public static ServiceAggregateOccurrence ToAggregate(this ServiceOccurrence occurrence) { if (occurrence == null) { throw new ArgumentNullException(nameof(occurrence)); } IEnumerable <DayOfWeek> days = null; if (occurrence.Days != null) { days = occurrence.Days.Select(d => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), d.DayId)); } return(new ServiceAggregateOccurrence { Id = occurrence.Id, Days = days, ServiceId = occurrence.ServiceId, StartDate = occurrence.StartDate, EndDate = occurrence.EndDate, StartTime = occurrence.StartTime, EndTime = occurrence.EndTime }); }