コード例 #1
0
        /*********************************************************/
        /*             AgreementType Implementations               */
        /*********************************************************/
        #region AgreementType Implementations
        public CreateAgreementTypeResponse CreateAgreementType(CreateAgreementTypeRequest request)
        {
            CreateAgreementTypeResponse response = new CreateAgreementTypeResponse();
            response.ExceptionState = false;

            AgreementType agreementType = new AgreementType();
            agreementType.Name = request.Name.ToUpper(new CultureInfo("tr-TR"));
            agreementType.Description = request.Description.ToUpper(new CultureInfo("tr-TR"));

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

                response.AgreementType = agreementType.ConvertToAgreementTypeView();

                return response;
            }

            object identityToken = _agreementTypeRepository.Add(agreementType);
            _unitOfWork.Commit();

            if (identityToken == null)
            {
                response.ExceptionState = true;
                response.ExceptionMessage = @"Sözleşme tipi kaydedilemedi. Lütfen daha sonra tekrar deneyin.";

                return response;
            }

            response.AgreementType = _agreementTypeRepository.FindBy((int)identityToken).ConvertToAgreementTypeView();

            return response;
        }
コード例 #2
0
        public UpdateAgreementTypeResponse UpdateAgreementType(UpdateAgreementTypeRequest request)
        {
            UpdateAgreementTypeResponse response = new UpdateAgreementTypeResponse();
            response.ExceptionState = false;

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

            if (agreementType.Name != _agreementTypeRepository.FindBy(request.Id).Name)
            {
                Query query = new Query();
                query.Add(Criterion.Create<AgreementType>(c => c.Name, request.Name, CriteriaOperator.Equal));
                if (_agreementTypeRepository.FindBy(query).Count() > 0)
                {
                    response.ExceptionState = true;
                    response.ExceptionMessage = @"Bu isimde bir sözleşme tipi zaten var. Lütfen sözleşme tipi adını benzersiz bir isim olarak düzenleyin.";

                    response.AgreementType = agreementType.ConvertToAgreementTypeView();

                    return response;
                }
            }

            _agreementTypeRepository.Save(agreementType);
            _unitOfWork.Commit();

            response.AgreementType = agreementType.ConvertToAgreementTypeView();

            return response;
        }