コード例 #1
0
        public async Task <ResponseDto <BaseModelDto> > DeleteCalendar(string calendarId)
        {
            var response = new ResponseDto <BaseModelDto>();
            var service  = await _googleCalendarService.GetCalendarService();

            if (service == null)
            {
                response.Errors.Add(ServiceErrors.SERVICE_ERROR);
                return(response);
            }

            var calendars = await GetListOfCalendars();

            if (calendars.ErrorOccurred)
            {
                response.Errors.Add(ServiceErrors.STH_WENT_WRONG_ERROR);
                return(response);
            }

            var exist = calendars.Object.CalendarList.Exists(cal => cal.Id == calendarId);

            if (!exist)
            {
                response.Errors.Add(ServiceErrors.CALENDAR_DOES_NOT_EXIST_ERROR);
                return(response);
            }

            var dbCalendar = await _calendarRepository.GetById(calendarId);

            if (dbCalendar == null)
            {
                response.Errors.Add(ServiceErrors.CALENDAR_DOES_NOT_EXIST_ERROR);
                return(response);
            }

            await service.Calendars.Delete(calendarId).ExecuteAsync();

            await _calendarRepository.Delete(dbCalendar);

            return(response);
        }
コード例 #2
0
        public async Task <Unit> Handle(AddNurseToCalendarCommand request, CancellationToken cancellationToken)
        {
            //var doctor = await _medicalRepository.GetByIdAsync(new MedicalStuffId(request.DoctorId));
            var doctor = await _medicalRepository.GetById(new MedicalStuffId(request.DoctorId));

            //var calendar = await _calendarRepository.GetByIdAsync(doctor.GetCalendarId());
            var calendar = await _calendarRepository.GetById(doctor.GetCalendarId());

            //calendar.AddAccesToCalendar(new MedicalStuffId(request.NurseId));
            calendar.AddAccesToCalendar(new MedicalStuffId(request.NurseId));

            await _calendarRepository.Add(calendar);


            //await _calendarRepository.Save();

            return(Unit.Value);
        }
コード例 #3
0
 public CalendarOfEvents GetById(string id)
 {
     return(_repository.GetById(id));
 }
コード例 #4
0
        public async Task Handle(CalendarCreatedDomainEvent @event, CancellationToken cancellationToken)
        {
            var calendar = await _calendarRepository.GetById(@event.CalendarId);

            Console.WriteLine($"|||||||||||||||||||| CalendarID: {@event.CalendarId.Value} ||||||||| Title: {calendar.GetCalendatTitle()} ||||||||||| OcuredOn: {@event.OccurredOn} ||||||||||||||||||||");
        }
コード例 #5
0
        public async Task <ResponseDto <BaseModelDto> > InsertEvent(AddEventBindingModel model, string calendarId)
        {
            var response = new ResponseDto <BaseModelDto>();
            var service  = await _googleCalendarService.GetCalendarService();

            if (service == null)
            {
                response.Errors.Add(ServiceErrors.SERVICE_ERROR);
                return(response);
            }

            var dbCalendar = await _calendarRepository.GetById(calendarId);

            if (dbCalendar == null)
            {
                response.Errors.Add(ServiceErrors.CALENDAR_DOES_NOT_EXIST_ERROR);
                return(response);
            }

            if (model.StartDate >= model.EndDate)
            {
                response.Errors.Add(ServiceErrors.START_DATE_GREATER_ERROR);
                return(response);
            }

            var validDate = ValidateDateTimeForInsert(model.StartDate, model.EndDate, dbCalendar);

            if (!validDate)
            {
                response.Errors.Add(ServiceErrors.EVENT_WHILE_OTHERS_ERROR);
                return(response);
            }

            var newEvent = new Event
            {
                Summary = model.Summary,
                Start   = new EventDateTime
                {
                    TimeZone = timezone,
                    DateTime = model.StartDate
                },
                End = new EventDateTime
                {
                    TimeZone = timezone,
                    DateTime = model.EndDate
                }
            };

            EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
            var createdEvent = request.Execute();

            var dbEvent = new GEvent
            {
                Id          = createdEvent.Id,
                Summary     = newEvent.Summary,
                StartDate   = model.StartDate,
                EndDate     = model.EndDate,
                Description = newEvent.Description,
                Calendar    = dbCalendar
            };

            await _eventRepository.Insert(dbEvent);

            return(response);
        }