public static string DisplayStartTime(this ShowVm show, CultureInfo culture) { var result = show.StartTime.HasValue && show.EndTime.HasValue ? show.StartTime.ToString("t", culture) : string.Empty; return(result); }
public static void UpdateByViewModel(ShowRecord record, ShowVm showVm) { record.DateModified = DateTime.UtcNow; record.Title = showVm.Title.TrimIt().StripTags(); record.Description = showVm.Description.TrimIt().StripTags(); record.StartTime = showVm.StartTime; record.EndTime = showVm.EndTime; record.DetailsUrl = showVm.DetailsUrl.TrimIt().StripTags(); record.IsDeleted = showVm.Destroy; }
private static void UpdateByViewModelPicture(EventMetadataRecord eventRec, ShowRecord record, ShowVm showVm, IStorageProvider storageProvider) { var previousPictureUrl = FileUtil.GetPictureUrl(record.Picture, storageProvider); if (previousPictureUrl != showVm.Picture) { record.Picture = FileUtil.ProcessUploadedPicture(record.Picture, showVm.Picture, Path.Combine("event", eventRec.Id.ToString(CultureInfo.InvariantCulture), "shows"), storageProvider); } }
public static string DisplayEndTime(this ShowVm show, CultureInfo culture) { var result = (show.EndTime ?? show.StartTime).ToString("t", culture); return(result); }
public static string DisplayTime(this ShowVm show, CultureInfo culture) { var result = DisplayStartTime(show, culture) + DisplayEndTime(show, culture); return(result); }
private IEnumerable <ValidationError> ValidateShow(ShowVm model, EventMetadataVm eventVm, string prefix = "") { var result = new List <ValidationError>(); var titleProperty = model.GetPropertyName(p => p.Title); if (string.IsNullOrEmpty(model.Title)) { result.Add(new ValidationError( prefix + titleProperty, T("Title can not be empty!").Text)); } else if (model.Title.Length > 255) { result.Add(new ValidationError( prefix + titleProperty, T("Title can not be larger than 255 characters!").Text)); } var pictureProperty = model.GetPropertyName(p => p.Picture); if (!string.IsNullOrEmpty(model.Picture)) { if (model.Picture.Length > 255) { result.Add(new ValidationError( prefix + pictureProperty, T("Picture url can not be larger than 255 characters!").Text)); } else if (!model.Picture.IsUrlValid()) { result.Add(new ValidationError( prefix + pictureProperty, T("Picture url is in bad format!").Text)); } } var detailsUrlProperty = model.GetPropertyName(p => p.DetailsUrl); if (!string.IsNullOrEmpty(model.DetailsUrl)) { if (model.DetailsUrl.Length > 255) { result.Add(new ValidationError( prefix + detailsUrlProperty, T("Details url can not be larger than 255 characters!").Text)); } else if (!model.DetailsUrl.IsUrlValid()) { result.Add(new ValidationError( prefix + detailsUrlProperty, T("Details url is in bad format!").Text)); } } var startTimeProperty = model.GetPropertyName(p => p.StartTime); if (model.StartTime.HasValue && model.EndTime.HasValue && model.StartTime.Value > model.EndTime.Value) { result.Add(new ValidationError( prefix + startTimeProperty, T("Show start time has to be less than or equal to the end time.").Text)); } var eventStartDate = eventVm.StartDate; var eventEndDate = eventVm.EndDate ?? eventVm.StartDate; if (model.StartTime.HasValue && eventStartDate.HasValue && (model.StartTime.Value < eventStartDate.Value.AddDays(-1) || (eventEndDate.HasValue && model.StartTime.Value > eventEndDate.Value.AddDays(1)))) { result.Add(new ValidationError( prefix + startTimeProperty, T("Show start time has to be between event start and end dates.").Text)); } var endTimeProperty = model.GetPropertyName(p => p.EndTime); if (model.EndTime.HasValue && eventStartDate.HasValue && (model.EndTime.Value < eventStartDate.Value.AddDays(-1) || (eventEndDate.HasValue && model.EndTime.Value > eventEndDate.Value.AddDays(2)))) { result.Add(new ValidationError( prefix + endTimeProperty, T("Show end time has to be between event start and end dates.").Text)); } return(result); }