Exemplo n.º 1
0
        /*********************************************************/
        /*             OperationCenterType Implementations               */
        /*********************************************************/
        #region OperationCenterType Implementations
        public CreateOperationCenterTypeResponse CreateOperationCenterType(CreateOperationCenterTypeRequest request)
        {
            CreateOperationCenterTypeResponse response = new CreateOperationCenterTypeResponse();
            response.ExceptionState = false;

            OperationCenterType operationCenterType = new OperationCenterType();
            operationCenterType.Name = request.Name.ToUpper(new CultureInfo("tr-TR"));
            operationCenterType.Description = request.Description.ToUpper(new CultureInfo("tr-TR"));

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

                response.OperationCenterType = operationCenterType.ConvertToOperationCenterTypeView();

                return response;
            }

            object identityToken = _operationCenterTypeRepository.Add(operationCenterType);
            _unitOfWork.Commit();

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

                return response;
            }

            response.OperationCenterType = _operationCenterTypeRepository.FindBy((int)identityToken).ConvertToOperationCenterTypeView();

            return response;
        }
Exemplo n.º 2
0
        public UpdateOperationCenterTypeResponse UpdateOperationCenterType(UpdateOperationCenterTypeRequest request)
        {
            UpdateOperationCenterTypeResponse response = new UpdateOperationCenterTypeResponse();
            response.ExceptionState = false;

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

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

                    response.OperationCenterType = operationCenterType.ConvertToOperationCenterTypeView();

                    return response;
                }
            }

            _operationCenterTypeRepository.Save(operationCenterType);
            _unitOfWork.Commit();

            response.OperationCenterType = operationCenterType.ConvertToOperationCenterTypeView();

            return response;
        }