Exemplo n.º 1
0
        public CalendarChangeModel GetCreateViewModel()
        {
            var model = new CalendarChangeModel
            {
                CalendarModel = new CalendarViewModel(),
                Colors        = this.colorService.GetAllColors(),
            };

            return(model);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateAsync(CalendarChangeModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            await this.calendarService.CreateFromAdminAsync(model.CalendarModel);

            return(this.RedirectToAction(nameof(this.Index)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> EditAsync(CalendarChangeModel model, string id)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var calendarModel = this.calendarService.MapCalendarViewModelToCalendar(model.CalendarModel, id);

            await this.calendarService.UpdateAsync(calendarModel, id);

            return(this.RedirectToAction(nameof(this.Index)));
        }
Exemplo n.º 4
0
        public CalendarChangeModel GetEditChangeViewModelById(string calendarId)
        {
            if (string.IsNullOrEmpty(calendarId))
            {
                throw new ArgumentException(InvalidPropertyErrorMessage);
            }

            var calendar       = this.calendarRepository.All().Where(x => x.Id == calendarId).To <CalendarViewModel>().First();
            var calendarResult = new CalendarChangeModel
            {
                CalendarModel = calendar,
                Colors        = this.colorService.GetAllColors(),
            };

            return(calendarResult);
        }