private CalendarEventDTO Create(CalendarEventViewModel viewModel) { try { log.Debug(CalendarEventViewModel.FormatCalendarEventViewModel(viewModel)); CalendarEventDTO calendarEvent = new CalendarEventDTO(); // copy values viewModel.UpdateDTO(calendarEvent, null); //RequestContext.Principal.Identity.GetUserId()); // audit calendarEvent.CreateBy = null; //RequestContext.Principal.Identity.GetUserId(); calendarEvent.CreateOn = DateTime.UtcNow; // add log.Debug("_calendarEventService.AddCalendarEvent - " + CalendarEventDTO.FormatCalendarEventDTO(calendarEvent)); int id = _calendarEventService.AddCalendarEvent(calendarEvent); calendarEvent.CalendarEventId = id; log.Debug("result: 'success', id: " + id); return(calendarEvent); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
private CalendarEventDTO Update(CalendarEventViewModel viewModel) { try { log.Debug(CalendarEventViewModel.FormatCalendarEventViewModel(viewModel)); // get log.Debug("_calendarEventService.GetCalendarEvent - calendarEventId: " + viewModel.CalendarEventId + " "); var existingCalendarEvent = _calendarEventService.GetCalendarEvent(viewModel.CalendarEventId); log.Debug("_calendarEventService.GetCalendarEvent - " + CalendarEventDTO.FormatCalendarEventDTO(existingCalendarEvent)); if (existingCalendarEvent != null) { // copy values viewModel.UpdateDTO(existingCalendarEvent, null); //RequestContext.Principal.Identity.GetUserId()); // update log.Debug("_calendarEventService.UpdateCalendarEvent - " + CalendarEventDTO.FormatCalendarEventDTO(existingCalendarEvent)); _calendarEventService.UpdateCalendarEvent(existingCalendarEvent); log.Debug("result: 'success'"); } else { log.Error("existingCalendarEvent: null, CalendarEventId: " + viewModel.CalendarEventId); } return(existingCalendarEvent); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }