Пример #1
0
        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"));
        }
Пример #2
0
        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);
        }