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)); }
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 = String.Empty, day = (int)ere.day, frequency = (int)ere.frequency, monthly_interval = (int)ere.monthly }; _db.Update(re, re.Id); //Get Descriptions for Event Dictionary <string, EventDesciption> descriptions = this._db.Query <EventDesciption>("SELECT * FROM ec_eventdescriptions WHERE eventid = @0", ere.id).ToDictionary(x => x.CultureCode); List <ILanguage> languages = Services.LocalizationService.GetAllLanguages().ToList(); foreach (var lang in languages) { if (!descriptions.ContainsKey(lang.CultureInfo.ToString())) { descriptions.Add(lang.CultureInfo.ToString(), new EventDesciption() { CultureCode = lang.CultureInfo.ToString(), EventId = ere.id, Id = 0, Type = (int)EventType.Recurring, CalendarId = ere.calendar }); } } ere.Descriptions = descriptions; 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, 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 }; //Get Descriptions for Event Dictionary <string, EventDesciption> descriptions = this._db.Query <EventDesciption>("SELECT * FROM ec_eventdescriptions WHERE eventid = @0 AND type = 1 AND calendarid = @1", id, e.calendarId).ToDictionary(x => x.CultureCode); List <ILanguage> languages = Services.LocalizationService.GetAllLanguages().ToList(); foreach (var lang in languages) { if (!descriptions.ContainsKey(lang.CultureInfo.ToString())) { descriptions.Add(lang.CultureInfo.ToString(), new EventDesciption() { CultureCode = lang.CultureInfo.ToString(), EventId = ere.id, Id = 0, Type = (int)EventType.Recurring, CalendarId = ere.calendar }); } } ere.Descriptions = descriptions; return(PartialView(ere)); }
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)); }