Exemple #1
0
        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;
            }
        }
Exemple #2
0
        public CalendarEventDTO GetCalendarEvent(int calendarEventId)
        {
            try
            {
                //Requires.NotNegative("calendarEventId", calendarEventId);

                log.Debug("calendarEventId: " + calendarEventId + " ");

                // get
                R_CalendarEvent t = Repository.GetCalendarEvent(calendarEventId);

                CalendarEventDTO dto = new CalendarEventDTO(t);

                log.Debug(CalendarEventDTO.FormatCalendarEventDTO(dto));

                return(dto);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Exemple #3
0
        public int AddCalendarEvent(CalendarEventDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(CalendarEventDTO.FormatCalendarEventDTO(dto));

                R_CalendarEvent t = CalendarEventDTO.ConvertDTOtoEntity(dto);

                // add
                id = Repository.AddCalendarEvent(t);
                dto.CalendarEventId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Exemple #4
0
        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;
            }
        }
Exemple #5
0
        public void DeleteCalendarEvent(CalendarEventDTO dto)
        {
            try
            {
                log.Debug(CalendarEventDTO.FormatCalendarEventDTO(dto));

                R_CalendarEvent t = CalendarEventDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteCalendarEvent(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Exemple #6
0
        public void UpdateCalendarEvent(CalendarEventDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "CalendarEventId");

                log.Debug(CalendarEventDTO.FormatCalendarEventDTO(dto));

                R_CalendarEvent t = CalendarEventDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateCalendarEvent(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }