public ActionResult EditRecurringEvent(EditRecurringEventModel ere) { List<EventLocation> locations = this._db.Query<EventLocation>("SELECT * FROM ec_locations").ToList(); locations.Insert(0, new EventLocation() { LocationName = "No Location", Id = 0 }); SelectList list = new SelectList(locations, "Id", "LocationName", ere.selectedLocation); ere.locations = list; if (!ModelState.IsValid) { TempData["StatusEditEvent"] = "Invalid"; return PartialView(ere); } TempData["StatusEditEvent"] = "Valid"; RecurringEvent re = new RecurringEvent() { Id = ere.id, title = ere.title, allDay = ere.allDay, calendarId = ere.calendar, locationId = ere.selectedLocation, description = ere.description, day = (int)ere.day, frequency = (int)ere.frequency, monthly_interval = (int)ere.monthly }; _db.Update(re, re.Id); return PartialView(ere); }
public ActionResult EditRecurringEvent(int id = 0) { List<EventLocation> locations = this._db.Query<EventLocation>("SELECT * FROM ec_locations").ToList(); locations.Insert(0, new EventLocation() { LocationName = "No Location", Id = 0 }); var e = _db.Single<RecurringEvent>(id); //Create SelectList with selected location SelectList list = new SelectList(locations, "Id", "LocationName", e.locationId); EditRecurringEventModel ere = new EditRecurringEventModel(){ title = e.title, description = e.description, allDay = e.allDay, id = e.Id, day = (DayOfWeekEnum)e.day, frequency = (FrequencyTypeEnum)e.frequency, monthly = (MonthlyIntervalEnum)e.monthly_interval, calendar = e.calendarId, locations = list, selectedLocation = e.locationId }; return PartialView(ere); }