public async Task <IActionResult> OnPost() { Event newEvent = new Event { Theme = ViewModel.Theme, DateAdded = DateTime.Now, StartingDate = ViewModel.StartingDate.Date, EndingDate = ViewModel.EndingDate.Date, StartingTime = ViewModel.StartingTime, Details = ViewModel.Details, }; // process file upload if (ViewModel.Banner != null) { using (var memoryStream = new MemoryStream()) { await ViewModel.Banner.CopyToAsync(memoryStream); newEvent.Banner = memoryStream.ToArray(); } } _ = await _eventData.AddEventAsync(newEvent); return(RedirectToPage()); }