예제 #1
0
        public UpdateCalendarDayTypeResponse UpdateCalendarDayType(UpdateCalendarDayTypeRequest request)
        {
            UpdateCalendarDayTypeResponse response = new UpdateCalendarDayTypeResponse();
            response.ExceptionState = false;

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

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

                    response.CalendarDayType = calendarDayType.ConvertToCalendarDayTypeView();

                    return response;
                }
            }

            _calendarDayTypeRepistory.Save(calendarDayType);
            _unitOfWork.Commit();

            response.CalendarDayType = calendarDayType.ConvertToCalendarDayTypeView();

            return response;
        }
예제 #2
0
        /*********************************************************/
        /*           CalendarDayType Implementations             */
        /*********************************************************/
        #region CalendarDayType Implementations
        public CreateCalendarDayTypeResponse CreateCalendarDayType(CreateCalendarDayTypeRequest request)
        {
            CreateCalendarDayTypeResponse response = new CreateCalendarDayTypeResponse();
            response.ExceptionState = false;

            CalendarDayType calendarDayType = new CalendarDayType();
            calendarDayType.Name = request.Name.ToUpper(new CultureInfo("tr-TR"));
            calendarDayType.Description = request.Description.ToUpper(new CultureInfo("tr-TR"));

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

                response.CalendarDayType = calendarDayType.ConvertToCalendarDayTypeView();

                return response;
            }

            object identityToken = _calendarDayTypeRepistory.Add(calendarDayType);
            _unitOfWork.Commit();

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

                return response;
            }

            response.CalendarDayType = _calendarDayTypeRepistory.FindBy((int)identityToken).ConvertToCalendarDayTypeView();

            return response;
        }