public async Task <IActionResult> Edit(EventUpdateViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } await this.eventsService.UpdateEvent( model.Id, model.Title, model.Description, model.Start, model.End, model.IsAllDay, model.IsRecurring, model.Color); return(this.RedirectToAction("All")); }
public void EventUpdateViewModelShouldHaveTitle() { var eventToTest = new EventUpdateViewModel { Id = 1, Title = null, Start = DateTime.UtcNow, Description = "ddd", Color = "sss", End = DateTime.Now, IsAllDay = false, IsRecurring = false, }; var validatorResults = new List <ValidationResult>(); var actual = Validator.TryValidateObject(eventToTest, new ValidationContext(eventToTest), validatorResults, true); Assert.False(actual); Assert.Single(validatorResults); }