示例#1
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;
        }
示例#2
0
        public UpdateCalendarResponse UpdateCalendar(UpdateCalendarRequest request)
        {
            UpdateCalendarResponse response = new UpdateCalendarResponse();
            response.ExceptionState = false;

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

            if (calendar.Name != _calendarRepository.FindBy(request.Id).Name)
            {
                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;
                }
            }

            _calendarRepository.Save(calendar);
            _unitOfWork.Commit();

            response.Calendar = calendar.ConvertToCalendarView();

            return response;
        }