Ejemplo n.º 1
0
        public ActionResult BulkEdit(ConferenceBulkEditCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(View(command));
            }

            var conferencesToEdit = new List <Conference>();

            foreach (var editCommand in command.Commands)
            {
                var conference = _repository.Load(editCommand.Id);
                conference.ChangeName(editCommand.Name);
                conference.ChangeCost(editCommand.Cost);
                conference.ChangeDates(editCommand.StartDate.Value, editCommand.EndDate.Value);
                conferencesToEdit.Add(conference);
            }

            _repository.BulkSave(conferencesToEdit);
            return(RedirectToAction("Index"));
        }