/// <inheritdoc/>
        public Calendar CreateCalendar(string profileId, string name)
        {
            Preconditions.NotEmpty("profileId", profileId);
            Preconditions.NotEmpty("name", name);

            var request = new HttpRequest();

            request.Method = "POST";
            request.Url    = CalendarsUrl;
            request.AddOAuthAuthorization(this.accessToken);

            var calendarRequest = new CreateCalendarRequest
            {
                ProfileId = profileId,
                Name      = name,
            };

            request.SetJsonBody(calendarRequest);

            var response = this.HttpClient.GetJsonResponse <CreateCalendarResponse>(request);

            return(response.ToCalendar());
        }
示例#2
0
        /*********************************************************/
        /*               Calendar Implementations                */
        /*********************************************************/
        #region Calendar Implementations
        public CreateCalendarResponse CreateCalendar(CreateCalendarRequest request)
        {
            CreateCalendarResponse response = new CreateCalendarResponse();
            response.ExceptionState = false;

            Calendar calendar = new Calendar();
            calendar.Name = request.Name.ToUpper(new CultureInfo("tr-TR"));
            calendar.Description = request.Description.ToUpper(new CultureInfo("tr-TR"));

            Query query = new Query();
            query.Add(Criterion.Create<Calendar>(c => c.Name, request.Name, CriteriaOperator.Equal));
            if (_calendarRepository.FindBy(query).Count() > 0)
            {
                response.ExceptionState = true;
                response.ExceptionMessage = @"Bu isimde bir takvim zaten var. Lütfen takvim adını benzersiz bir isim olarak düzenleyin.";

                response.Calendar = calendar.ConvertToCalendarView();

                return response;
            }

            object identityToken = _calendarRepository.Add(calendar);
            _unitOfWork.Commit();

            if (identityToken == null)
            {
                response.ExceptionState = true;
                response.ExceptionMessage = @"Takvim kaydedilemedi. Lütfen daha sonra tekrar deneyin.";

                return response;
            }

            response.Calendar = _calendarRepository.FindBy((int)identityToken).ConvertToCalendarView();

            return response;
        }