public IActionResult EditPost(string id) { var model = _calendarQueryService.GetEventById(id); if (model == null) { model = _calendarQueryService.GetDefaultModel(); } ViewData["masterId"] = "123456"; return(View("~/Views/Admin/Calendar/EditEvent.cshtml", model)); }
public async Task <IViewComponentResult> InvokeAsync(string id, bool allEventGroups = false) { var userContext = _userContextAccessor.GetContext(); var eventGroups = new List <CalendarEventGroup>(); //Get Event or set default ViewData["eventId"] = id; var theEvent = _calendarQueryService.GetEventById(id); var allMyGroups = !allEventGroups ? _calendarQueryService.GetEventGroupsByUserId(userContext.UserId) : _calendarQueryService.GetSharedEventGroups(_calendarSecurity.GetEventGroupsSharedWithMe(), userContext.UserId); //TODO add my groups or option to add all other groups ViewData["EventGroups"] = allMyGroups; ViewData["AllEventGroups"] = allEventGroups; if (theEvent == null) { theEvent = new CalendarEvent(); } else { foreach (var refObject in theEvent.EventGroupEvents) { refObject.Event = null; } } return(View(theEvent)); }
public async Task <IViewComponentResult> InvokeAsync(string eventId, string day, string hour) { var calEvent = new CalendarEvent(); if (string.IsNullOrEmpty(eventId)) { calEvent = _calendarQueryService.GetDefaultModel(); if (!string.IsNullOrEmpty(day)) { //fix selected date and time before parsing calEvent.EventStart = DateTime.Parse(day.Replace('~', '/') + ' ' + hour.Replace('~', ' ')); calEvent.EventEnd = calEvent.EventStart.AddMinutes(30); } } else { calEvent = _calendarQueryService.GetEventById(eventId); } foreach (var refObject in calEvent.EventGroupEvents) { refObject.Event = null; } return(View(calEvent)); }
public async Task <IViewComponentResult> InvokeAsync(string eventId) { IList <string> testList = new List <string>(); var calEvent = _calendarQueryService.GetEventById(eventId); return(View(calEvent)); }
//[HttpPost, Route("/api/content/Calendar/post")] public IActionResult UpdateCalendarEvent(CalendarEvent model) { if (ModelState.IsValid) { var userContext = _userContextAccessor.GetContext(); Ensure.NotNull(userContext, "User context is missing."); Ensure.NotNullOrEmpty(userContext.UserId, "Cannot resolve user information."); var existingEvent = _calendarQueryService.GetEventById(model.EventId); if (existingEvent == null) { model.Posted = DateTime.Now; model.Title = string.IsNullOrEmpty(model.Title) ? "" : model.Title; model.SiteId = _siteContext.SiteId; model.UserId = userContext.UserId; //model.EventId = Guid.NewGuid().ToString("N"); model = _calendarQueryService.SaveEvent(model); return(Ok(model)); } else { existingEvent.Title = string.IsNullOrEmpty(model.Title) ? "" : model.Title; existingEvent.EventStart = model.EventStart; existingEvent.EventEnd = model.EventEnd; existingEvent.Posted = DateTime.Now; existingEvent.Style = model.Style; existingEvent.Description = model.Description; existingEvent.Phone = model.Phone; existingEvent.BackgroundColor = model.BackgroundColor; existingEvent.AllDayEvent = model.AllDayEvent; existingEvent.IsRecurrent = model.IsRecurrent; existingEvent.Location = model.Location; existingEvent.ShowOrganizerName = model.ShowOrganizerName; existingEvent.ShowPhoneNumber = model.ShowPhoneNumber; existingEvent.Url = model.Url; existingEvent.LinkTarget = model.LinkTarget; existingEvent.RecurrenceDetails.Count = model.RecurrenceDetails?.Count; existingEvent.RecurrenceDetails.DayOfMonth = model.RecurrenceDetails?.DayOfMonth; existingEvent.RecurrenceDetails.DaysOfWeek = model.RecurrenceDetails?.DaysOfWeek; existingEvent.RecurrenceDetails.EndDate = model.RecurrenceDetails?.EndDate; existingEvent.RecurrenceDetails.Frequency = model.RecurrenceDetails?.Frequency; existingEvent.RecurrenceDetails.Interval = model.RecurrenceDetails.Interval; existingEvent.RecurrenceDetails.Months = model.RecurrenceDetails?.Months; _calendarQueryService.UpdateEvent(existingEvent); return(Ok(model)); } } return(BadRequest(ModelState)); }