/*********************************************************/ /* Company Implementations */ /*********************************************************/ #region Company Implementations public CreateCompanyResponse CreateCompany(CreateCompanyRequest request) { CreateCompanyResponse response = new CreateCompanyResponse(); response.ExceptionState = false; Company company = new Company(); company.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); company.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); company.IsActive = request.IsActive; company.CompanyType = _companyTypeRepository.FindBy(request.CompanyTypeId); company.ParentCompany = _companyRepository.FindBy(request.ParentCompanyId ?? 0); Query query = new Query(); query.Add(Criterion.Create<Company>(c => c.ParentCompany, null, CriteriaOperator.IsNull)); if (company.ParentCompany == null && _companyRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Zaten bir ana firma var. Lütfen oluşturmaya çalıştığınız firmanın bağlı olduğu firmayı seçiniz."; return response; } query = new Query(); query.Add(Criterion.Create<Company>(c => c.Name, company.Name, CriteriaOperator.Equal)); if (_companyRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir firma zaten var. Lütfen farklı bir firma ekleyin ya da mevcut firmalardan birini düzenleyin."; return response; } object identityToken = _companyRepository.Add(company); _unitOfWork.Commit(); if (identityToken == null) { response.ExceptionState = true; response.ExceptionMessage = @"Firma kaydedilemedi. Lütfen daha sonra tekrar deneyin."; return response; } response.Company = _companyRepository.FindBy((int)identityToken).ConvertToCompanyView(); return response; }
/*********************************************************/ /* Project Implementations */ /*********************************************************/ #region Project Implementations public CreateProjectResponse CreateProject(CreateProjectRequest request) { CreateProjectResponse response = new CreateProjectResponse(); response.ExceptionState = false; Project project = new Project(); project.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); project.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); project.Company = _companyRepository.FindBy(request.CompanyId); project.ProjectStatus = _projectStatusRepository.FindBy(request.ProjectStatusId); project.ProjectType = _projectTypeRepository.FindBy(request.ProjectTypeId); project.StartDate = request.StartDate; project.EndDate = request.EndDate; Query query = new Query(); query.Add(Criterion.Create<Project>(c => c.Name, project.Name, CriteriaOperator.Equal)); if (_projectRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir proje zaten var. Lütfen farklı bir proje ekleyin ya da mevcut projelerden birini düzenleyin."; return response; } object identityToken = _projectRepository.Add(project); _unitOfWork.Commit(); if (identityToken == null) { response.ExceptionState = true; response.ExceptionMessage = @"Proje kaydedilemedi. Lütfen daha sonra tekrar deneyin."; return response; } response.Project = _projectRepository.FindBy((int)identityToken).ConvertToProjectView(); return response; }
/*********************************************************/ /* 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; }
/*********************************************************/ /* 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; }
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; }
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; }
public DeleteAgreementStatusResponse DeleteAgreementStatus(DeleteAgreementStatusRequest request) { DeleteAgreementStatusResponse response = new DeleteAgreementStatusResponse(); response.ExceptionState = false; Query query = new Query(); query.Add(Criterion.Create<Agreement>(c => c.AgreementStatus.Id, request.Id, CriteriaOperator.Equal)); if (_agreementRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Silmek istediğiniz sözleşme durumunu kullanan sözleşmeler var. Lütfen önce bu sözleşmeleri silip ya da düzenleyip tekrar deneyin."; response.AgreementStatuses = _agreementStatusRepository.FindAll().ConvertToAgreementStatusSummaryView(); return response; } _agreementStatusRepository.Remove(request.Id); _unitOfWork.Commit(); response.AgreementStatuses = _agreementStatusRepository.FindAll().ConvertToAgreementStatusSummaryView(); return response; }
/*********************************************************/ /* OperationCenterStatus Implementations */ /*********************************************************/ #region OperationCenterStatus Implementations public CreateOperationCenterStatusResponse CreateOperationCenterStatus(CreateOperationCenterStatusRequest request) { CreateOperationCenterStatusResponse response = new CreateOperationCenterStatusResponse(); response.ExceptionState = false; OperationCenterStatus operationCenterStatus = new OperationCenterStatus(); operationCenterStatus.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); operationCenterStatus.Description = request.Description.ToUpper(new CultureInfo("tr-TR")); Query query = new Query(); query.Add(Criterion.Create<OperationCenterStatus>(c => c.Name, request.Name, CriteriaOperator.Equal)); if (_operationCenterStatusRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir faaliyet merkezi durumu zaten var. Lütfen faaliyet merkezi durumu adını benzersiz bir isim olarak düzenleyin."; response.OperationCenterStatus = operationCenterStatus.ConvertToOperationCenterStatusView(); return response; } object identityToken = _operationCenterStatusRepository.Add(operationCenterStatus); _unitOfWork.Commit(); if (identityToken == null) { response.ExceptionState = true; response.ExceptionMessage = @"Faaliyet merkezi durumu kaydedilemedi. Lütfen daha sonra tekrar deneyin."; return response; } response.OperationCenterStatus = _operationCenterStatusRepository.FindBy((int)identityToken).ConvertToOperationCenterStatusView(); return response; }
public DeleteOperationCenterStatusResponse DeleteOperationCenterStatus(DeleteOperationCenterStatusRequest request) { DeleteOperationCenterStatusResponse response = new DeleteOperationCenterStatusResponse(); response.ExceptionState = false; Query query = new Query(); query.Add(Criterion.Create<OperationCenter>(c => c.OperationCenterStatus.Id, request.Id, CriteriaOperator.Equal)); if (_operationCenterRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Silmek istediğini faaliyet merkezi durumunu kullanan faaliyet merkezleri var. Lütfen önce bu faaliyet merkezlerini silip ya da düzenleyip tekrar deneyin."; response.OperationCenterStatuses = _operationCenterStatusRepository.FindAll().ConvertToOperationCenterStatusSummaryView(); return response; } _operationCenterStatusRepository.Remove(request.Id); _unitOfWork.Commit(); response.OperationCenterStatuses = _operationCenterStatusRepository.FindAll().ConvertToOperationCenterStatusSummaryView(); return response; }
public UpdateProjectResponse UpdateProject(UpdateProjectRequest request) { UpdateProjectResponse response = new UpdateProjectResponse(); response.ExceptionState = false; Project project = new Project(); project.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); project.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); project.Company = _companyRepository.FindBy(request.CompanyId); project.ProjectStatus = _projectStatusRepository.FindBy(request.ProjectStatusId); project.ProjectType = _projectTypeRepository.FindBy(request.ProjectTypeId); project.StartDate = request.StartDate; project.EndDate = request.EndDate; if (project.Name != _projectRepository.FindBy(request.Id).Name) { Query query = new Query(); query.Add(Criterion.Create<Project>(c => c.Name, project.Name, CriteriaOperator.Equal)); if (_projectStatusRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir proje zaten var. Lütfen proje adını benzersiz bir isim olarak düzenleyin."; response.Project = project.ConvertToProjectView(); return response; } } _projectRepository.Save(project); _unitOfWork.Commit(); response.Project = project.ConvertToProjectView(); return response; }
public void AddSubQuery(Query subQuery) { _subQueries.Add(subQuery); }
/*********************************************************/ /* ProjectStatus Implementations */ /*********************************************************/ #region ProjectStatus Implementations public CreateProjectStatusResponse CreateProjectStatus(CreateProjectStatusRequest request) { CreateProjectStatusResponse response = new CreateProjectStatusResponse(); response.ExceptionState = false; ProjectStatus projectStatus = new ProjectStatus(); projectStatus.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); projectStatus.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); Query query = new Query(); query.Add(Criterion.Create<ProjectStatus>(c => c.Name, projectStatus.Name, CriteriaOperator.Equal)); if (_projectStatusRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir proje durumu zaten var. Lütfen proje durumu adını benzersiz bir isim olarak düzenleyin."; response.ProjectStatus = projectStatus.ConvertToProjectStatusView(); return response; } object identityToken = _projectStatusRepository.Add(projectStatus); _unitOfWork.Commit(); if (identityToken == null) { response.ExceptionState = true; response.ExceptionMessage = @"Proje durumu kaydedilemedi. Lütfen daha sonra tekrar deneyin."; return response; } response.ProjectStatus = _projectStatusRepository.FindBy((int)identityToken).ConvertToProjectStatusView(); return response; }
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; }
public DeleteProjectTypeResponse DeleteProjectType(DeleteProjectTypeRequest request) { DeleteProjectTypeResponse response = new DeleteProjectTypeResponse(); response.ExceptionState = false; Query query = new Query(); query.Add(Criterion.Create<Project>(c => c.ProjectType.Id, request.Id, CriteriaOperator.Equal)); if (_projectRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Silmek istediğini proje tipini kullanan projeler var. Lütfen önce bu projeleri silip ya da düzenleyip tekrar deneyin."; response.ProjectTypes = _projectTypeRepository.FindAll().ConvertToProjectTypeSummaryView(); return response; } _projectTypeRepository.Remove(request.Id); _unitOfWork.Commit(); response.ProjectTypes = _projectTypeRepository.FindAll().ConvertToProjectTypeSummaryView(); return response; }
public UpdateCompanyResponse UpdateCompany(UpdateCompanyRequest request) { UpdateCompanyResponse response = new UpdateCompanyResponse(); response.ExceptionState = false; Company company = new Company(); company.Id = request.Id; company.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); company.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); company.IsActive = request.IsActive; company.CompanyType = _companyTypeRepository.FindBy(request.CompanyTypeId); company.ParentCompany = _companyRepository.FindBy(request.ParentCompanyId ?? 0); Query query = new Query(); if (company.ParentCompany == null) { query.Add(Criterion.Create<Company>(c => c.Id, company.Id, CriteriaOperator.NotEqual)); query.Add(Criterion.Create<Company>(c => c.ParentCompany, null, CriteriaOperator.IsNull)); if (_companyRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Zaten bir ana firma var. Lütfen oluşturmaya çalıştığınız firmanın bağlı olduğu firmayı seçiniz."; return response; } } if (company.Name != _companyRepository.FindBy(request.Id).Name) { query = new Query(); query.Add(Criterion.Create<Company>(c => c.Name, company.Name, CriteriaOperator.Equal)); if (_companyRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir firma zaten var. Lütfen firma adını benzersiz bir isim olarak düzenleyin."; response.Company = company.ConvertToCompanyView(); return response; } } _companyRepository.Save(company); _unitOfWork.Commit(); response.Company = company.ConvertToCompanyView(); return response; }
/*********************************************************/ /* CompanyType Implementations */ /*********************************************************/ #region CompanyType Implementations public CreateCompanyTypeResponse CreateCompanyType(CreateCompanyTypeRequest request) { CreateCompanyTypeResponse response = new CreateCompanyTypeResponse(); response.ExceptionState = false; CompanyType companyType = new CompanyType(); companyType.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); companyType.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); Query query = new Query(); query.Add(Criterion.Create<CompanyType>(c => c.Name, companyType.Name, CriteriaOperator.Equal)); if (_companyTypeRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir firma faaliyet alanı zaten var. Lütfen farklı bir faaliyet alanı ekleyin ya da mevcut faaliyet alanlarından birini düzenleyin."; return response; } object identityToken = _companyTypeRepository.Add(companyType); _unitOfWork.Commit(); if (identityToken == null) { response.ExceptionState = true; response.ExceptionMessage = @"Firma faaliyet alanı kaydedilemedi. Lütfen daha sonra tekrar deneyin."; return response; } response.CompanyType = _companyTypeRepository.FindBy((int)identityToken).ConvertToCompanyTypeView(); return response; }
public DeleteCompanyTypeResponse DeleteCompanyType(DeleteCompanyTypeRequest request) { DeleteCompanyTypeResponse response = new DeleteCompanyTypeResponse(); response.ExceptionState = false; Query query = new Query(); query.Add(Criterion.Create<Company>(c => c.CompanyType.Id, request.Id, CriteriaOperator.Equal)); if (_companyRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Silmek istediğiniz faaliyet alanını kullanan firmalar var. Lütfen önce bu firmaları silip ya da düzenleyip tekrar deneyin."; response.CompanyTypes = _companyTypeRepository.FindAll().ConvertToCompanyTypeSummaryView(); return response; } _companyTypeRepository.Remove(request.Id); _unitOfWork.Commit(); response.CompanyTypes = _companyTypeRepository.FindAll().ConvertToCompanyTypeSummaryView(); return response; }
public UpdateCompanyTypeResponse UpdateCompanyType(UpdateCompanyTypeRequest request) { UpdateCompanyTypeResponse response = new UpdateCompanyTypeResponse(); response.ExceptionState = false; CompanyType companyType = new CompanyType(); companyType.Id = request.Id; companyType.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); companyType.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); if (companyType.Name != _companyTypeRepository.FindBy(request.Id).Name) { Query query = new Query(); query.Add(Criterion.Create<CompanyType>(c => c.Name, companyType.Name, CriteriaOperator.Equal)); if (_companyTypeRepository.FindBy(query).Count() > 0) { response.ExceptionState = true; response.ExceptionMessage = @"Bu isimde bir firma faaliyet alanı zaten var. Lütfen faaliyet alanı adını benzersiz bir isim olarak düzenleyin."; response.CompanyType = companyType.ConvertToCompanyTypeView(); return response; } } _companyTypeRepository.Save(companyType); _unitOfWork.Commit(); response.CompanyType = companyType.ConvertToCompanyTypeView(); return response; }