public CalendarChangeModel GetCreateViewModel() { var model = new CalendarChangeModel { CalendarModel = new CalendarViewModel(), Colors = this.colorService.GetAllColors(), }; return(model); }
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))); }
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))); }
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); }