public UpdateProjectStatusResponse UpdateProjectStatus(UpdateProjectStatusRequest request) { UpdateProjectStatusResponse response = new UpdateProjectStatusResponse(); response.ExceptionState = false; ProjectStatus projectStatus = new ProjectStatus(); projectStatus.Id = request.Id; projectStatus.Name = request.Name.ToUpper(new CultureInfo("tr-TR")); projectStatus.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR")); if (projectStatus.Name != _projectStatusRepository.FindBy(request.Id).Name) { 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; } } _projectStatusRepository.Save(projectStatus); _unitOfWork.Commit(); response.ProjectStatus = projectStatus.ConvertToProjectStatusView(); return response; }
/*********************************************************/ /* 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; }