/// <summary> /// Gets the contracts. /// </summary> /// <param name="accessToken">The access token.</param> /// <param name="estateId">The estate identifier.</param> /// <param name="contractId">The contract identifier.</param> /// <param name="includeProducts"></param> /// <param name="includeProductsWithFees"></param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> public async Task <ContractResponse> GetContract(String accessToken, Guid estateId, Guid contractId, Boolean includeProducts, Boolean includeProductsWithFees, CancellationToken cancellationToken) { ContractResponse response = null; String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/{contractId}?includeProducts={includeProducts}&includeProductsWithFees={includeProductsWithFees}"); try { // Add the access token to the client headers this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); // Make the Http Call here HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); // Process the response String content = await this.HandleResponse(httpResponse, cancellationToken); // call was successful so now deserialise the body to the response object response = JsonConvert.DeserializeObject <ContractResponse>(content); } catch (Exception ex) { // An exception has occurred, add some additional information to the message Exception exception = new Exception($"Error getting contract {contractId} for estate {estateId}.", ex); throw exception; } return(response); }
public void ModelFactory_Contract_ContractWithProductsAndFees_IsConverted() { Contract contractModel = TestData.ContractModelWithProductsAndTransactionFees; ModelFactory modelFactory = new ModelFactory(); ContractResponse contractResponse = modelFactory.ConvertFrom(contractModel); contractResponse.ShouldNotBeNull(); contractResponse.EstateId.ShouldBe(contractModel.EstateId); contractResponse.OperatorId.ShouldBe(contractModel.OperatorId); contractResponse.ContractId.ShouldBe(contractModel.ContractId); contractResponse.Description.ShouldBe(contractModel.Description); contractResponse.Products.ShouldNotBeNull(); contractResponse.Products.ShouldHaveSingleItem(); ContractProduct contractProduct = contractResponse.Products.Single(); Product expectedContractProduct = contractModel.Products.Single(); contractProduct.ProductId.ShouldBe(expectedContractProduct.ProductId); contractProduct.Value.ShouldBe(expectedContractProduct.Value); contractProduct.DisplayText.ShouldBe(expectedContractProduct.DisplayText); contractProduct.Name.ShouldBe(expectedContractProduct.Name); contractProduct.TransactionFees.ShouldNotBeNull(); contractProduct.TransactionFees.ShouldHaveSingleItem(); ContractProductTransactionFee productTransactionFee = contractProduct.TransactionFees.Single(); ContractProductTransactionFee expectedProductTransactionFee = contractProduct.TransactionFees.Single(); productTransactionFee.TransactionFeeId.ShouldBe(expectedProductTransactionFee.TransactionFeeId); productTransactionFee.Value.ShouldBe(expectedProductTransactionFee.Value); productTransactionFee.CalculationType.ShouldBe(expectedProductTransactionFee.CalculationType); productTransactionFee.Description.ShouldBe(expectedProductTransactionFee.Description); }
private static void ChooseContractHandler(PacketHeader header, Connection connection, byte[] info) { ContractRequest contract; using (MemoryStream stream = new MemoryStream(info)) { contract = Serializer.Deserialize <ContractRequest>(stream); } Promise promise = AskUser.AskPromise(contract); GameMode gameMode = GameMode.ClassicClover; if (promise != Promise.Passe && promise != Promise.Coinche && promise != Promise.ReCoinche) { gameMode = AskUser.AskGameMode(); } if (!Lobby.IsGameStarted) { return; } using (MemoryStream streamResp = new MemoryStream()) { ContractResponse resp = new ContractResponse { Promise = promise, GameMode = gameMode }; Serializer.Serialize(streamResp, resp); connection.SendObject("ChooseContractResp", streamResp.ToArray()); Console.WriteLine("Response sent !"); } }
public void WillRespondWith(ContractResponse response) { if (buildingContract.Request == null) { throw new Exception("Request not defined for response"); } buildingContract.Response = response; contracts.Add(buildingContract); buildingContract = new Contract(); }
public void ModelFactory_Contract_NullContract_IsConverted() { Contract contractModel = null; ModelFactory modelFactory = new ModelFactory(); ContractResponse contractResponse = modelFactory.ConvertFrom(contractModel); contractResponse.ShouldBeNull(); }
public ContractResponse ContractApplicationSend(ContractRequest request) { var result = new ContractResponse(); var query = new ContractApplicationSend.Query { Request = request, Responce = result }; _mediator.Send(query).Wait(); return(result); }
public ContractResponse ConvertFrom(Contract contract) { if (contract == null) { return(null); } ContractResponse contractResponse = new ContractResponse { ContractId = contract.ContractId, EstateId = contract.EstateId, OperatorId = contract.OperatorId, OperatorName = contract.OperatorName, Description = contract.Description }; if (contract.Products != null && contract.Products.Any()) { contractResponse.Products = new List <ContractProduct>(); contract.Products.ForEach(p => { ContractProduct contractProduct = new ContractProduct { ProductId = p.ProductId, Value = p.Value, DisplayText = p.DisplayText, Name = p.Name }; if (p.TransactionFees != null && p.TransactionFees.Any()) { contractProduct.TransactionFees = new List <ContractProductTransactionFee>(); p.TransactionFees.ForEach(tf => { ContractProductTransactionFee transactionFee = new ContractProductTransactionFee { TransactionFeeId = tf.TransactionFeeId, Value = tf.Value, Description = tf.Description, }; transactionFee.CalculationType = Enum.Parse <CalculationType>(tf.CalculationType.ToString()); contractProduct.TransactionFees.Add(transactionFee); }); } contractResponse.Products.Add(contractProduct); }); } return(contractResponse); }
public void UpdateFromResponse(ContractResponse response) { ServerId = response.ServerId; CodeId = response.CodeId; ConCode = response.ConCode; ClientId = response.FkClientServerId; AdresseId = response.FkAddressServerId; DateStart = response.ConDateStart; DateEnd = response.ConDateEnd; Minute = response.ConMinute; Budget = response.ConBudget; IsActif = response.IsActif; Title = response.Title; }
public void ModelFactory_Contract_ContractOnly_IsConverted() { Contract contractModel = TestData.ContractModel; ModelFactory modelFactory = new ModelFactory(); ContractResponse contractResponse = modelFactory.ConvertFrom(contractModel); contractResponse.ShouldNotBeNull(); contractResponse.EstateId.ShouldBe(contractModel.EstateId); contractResponse.OperatorId.ShouldBe(contractModel.OperatorId); contractResponse.OperatorName.ShouldBe(contractModel.OperatorName); contractResponse.ContractId.ShouldBe(contractModel.ContractId); contractResponse.Description.ShouldBe(contractModel.Description); contractResponse.Products.ShouldBeNull(); }
/// <summary> /// Updates the Contract. /// </summary> /// <param name="Contract">The Contract.</param> /// <returns></returns> public ContractResponse UpdateContract(ContractEntity Contract) { var response = new ContractResponse { Acknowledge = AcknowledgeType.Success }; try { var Contracts = ContractDao.GetContractByContractNo(Contract.ContractNo); if (Contracts != null && Contract.ContractId != Contracts.ContractId) { response.Acknowledge = AcknowledgeType.Failure; response.Message = @"Số hợp đồng " + Contract.ContractNo + @" đã tồn tại!"; return(response); } response.Message = ContractDao.UpdateContract(Contract); if (!string.IsNullOrEmpty(response.Message)) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.ContractId = Contract.ContractId; foreach (var item in Contract.ContractDetails) { if (item.ContractDetailID == null) { item.ContractDetailID = Guid.NewGuid().ToString(); item.ContractID = Contract.ContractId; item.Stt = Contract.ContractDetails.IndexOf(item); ContractDao.InsertContractDetail(item); } else { ContractDao.UpdateContractDetail(item); } } return(response); } catch (Exception ex) { response.Message = ex.Message; return(response); } }
public async Task <IActionResult> GetAllContracts() { var model = await _contractService.GetContractsAsync(); if (model == null) { return(NotFound()); } var response = new ContractResponse { Code = "success", Message = "contract.all.get.success", Data = model }; return(Created("", response)); }
public ContractResponse BuildContract(IList <RentalRequest> requests) { var rentalHelper = new RentalHelper(); rentalHelper.ValidateRentalRequests(requests); int requestCount = 0; var response = new ContractResponse { CreatedAt = DateTime.Now }; var details = new List <DetailResponse>(); foreach (var request in requests) { var detail = detailStrategy[request.RentalType](request); response.Total += detail.RentalCost; details.Add(detail); if (!response.HasFamilyDiscount) { requestCount++; if (requestCount >= 3 && requestCount <= 5) { response.HasFamilyDiscount = true; requestCount = 0; } } } response.Details = details; if (response.HasFamilyDiscount) { var rentalDiscount = response.Total * 0.30m; response.Discount = rentalDiscount; response.Total -= rentalDiscount; } return(response); }
/// <summary> /// Get a particular mapping /// </summary> /// <param name="request"></param> /// <returns></returns> public ContractResponse <MappingResponse> RequestMapping(GetMappingRequest request) { // Get the entity var mapping = this.repository.FindOne <TMapping>(request.MappingId); if (mapping == null || request.EntityId != mapping.Entity.Id) { return(new ContractResponse <MappingResponse> { Error = new ContractError { Type = ErrorType.NotFound }, IsValid = false }); } if (mapping.Entity.Id != request.EntityId) { return(new ContractResponse <MappingResponse> { Error = new ContractError { Type = ErrorType.NotFound }, IsValid = false }); } var mr = new MappingResponse(); mr.Mappings.Add(this.MappingEngine.Map <TMapping, MdmId>(mapping)); var response = new ContractResponse <MappingResponse> { Contract = mr, Version = mapping.Entity.Version, IsValid = true }; return(response); }
/// <summary> /// Deletes the Contract. /// </summary> /// <param name="Contract">The Contract.</param> /// <returns></returns> public ContractResponse DeleteContract(string ContractId) { var response = new ContractResponse { Acknowledge = AcknowledgeType.Success }; try { var Contract = ContractDao.GetContract(ContractId); var ContractDetail = ContractDao.GetContractDetail(ContractId); response.Message = ContractDao.DeleteContract(ContractId); if (!string.IsNullOrEmpty(response.Message)) { if (response.Message.Contains("FK") ) { response.Message = @"Bạn không thể xóa hợp đồng " + Contract.ContractNo + " , vì đã có phát sinh trong chứng từ hoặc danh mục liên quan!"; } response.Acknowledge = AcknowledgeType.Failure; return(response); } if (!string.IsNullOrEmpty(response.Message)) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.ContractId = ContractId; foreach (var item in ContractDetail) { ContractDao.DeleteContractDetail(ContractId); } return(response); } catch (Exception ex) { response.Message = ex.Message; return(response); } }
public void UnsuccessfulMatchReturnsNotFound() { // Arrange var wrapper = new Mock <IWebOperationContextWrapper>(); var service = new Mock <IMdmService <Party, MDM.Party> >(); var feedFactory = new Mock <IFeedFactory>(); Container.RegisterInstance(wrapper.Object); Container.RegisterInstance(service.Object); Container.RegisterInstance(feedFactory.Object); wrapper.Setup(contextWrapper => contextWrapper.QueryParameters) .Returns(() => new NameValueCollection()); wrapper.Setup(x => x.Headers) .Returns(() => new WebHeaderCollection()); var contract = new ContractResponse <Party> { Error = new ContractError { Type = ErrorType.NotFound }, IsValid = false }; service.Setup(x => x.Request(It.IsAny <GetRequest>())).Returns(contract); var wcfService = new PartyService(); // Act try { wcfService.Get("1"); } catch (WebFaultException <Fault> ex) { Assert.AreEqual(HttpStatusCode.NotFound, ex.StatusCode, "Status code differs"); } }
public Contract(ContractResponse response) { if (!string.IsNullOrWhiteSpace(response.K) && Guid.TryParse(response.K, out Guid id)) { Id = id; } else { Id = Guid.NewGuid(); } ServerId = response.ServerId; CodeId = response.CodeId; ConCode = response.ConCode; Title = response.Title; ClientId = response.FkClientServerId; AdresseId = response.FkAddressServerId; DateStart = response.ConDateStart; DateEnd = response.ConDateEnd; Minute = response.ConMinute; Budget = response.ConBudget; IsActif = response.IsActif; SynchronizationDate = response.SynchronizationDate ?? DateTime.Now; }
public ContractResponse GetScoringOffersManagerContract() => ContractResponse.FromOptions(_nethereumOptions.ScoringOffersManagerContract);
/// <summary> /// Добавление договора /// </summary> /// <param name="request">Входные параметры</param> /// <param name="response">Данные для ответа</param> /// <returns></returns> public ContractResponse AddContract(ContractRequest request, ContractResponse response) { var typeId = _dictionaryHelper.GetDictionaryIdByExternalId(nameof(DicDocumentType), request.DocumentType.Id); DicCustomer customer; customer = Mapper.Map <DicCustomer>( request, el => el.Items[nameof(customer.TypeId)] = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerType), request.Addressee.CustomerType.Id).Id); customer.CountryId = _dictionaryHelper.GetDictionaryIdByExternalId(nameof(DicCountry), request.Addressee.CountryInfo.Id); var addressee = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(customer); var correspondence = request.CorrespondenceAddress; var protectionDocTypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicProtectionDocType), DicProtectionDocTypeCodes.ProtectionDocTypeContractCode); #region Добавление договора var contract = new Contract { ProtectionDocTypeId = protectionDocTypeId, Description = request.DocumentDescriptionRu, ReceiveTypeId = int.Parse(DicReceiveTypeCodes.ElectronicFeed), DivisionId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDivision), DicDivisionCodes.RGP_NIIS), AddresseeId = addressee.Id, AddresseeAddress = addressee.Address, StatusId = 1 }; CreateContract(Mapper.Map(request, contract)); #endregion #region Добавление адресата для переписки if (correspondence != null) { var correspondenceCustomer = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(new DicCustomer { TypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicCustomerType), DicCustomerTypeCodes.Undefined), NameRu = correspondence.CustomerName, Phone = correspondence.Phone, PhoneFax = correspondence.Fax, Email = correspondence.Email }); _niisWebContext.ContractCustomers.Add(new ContractCustomer { CustomerId = correspondenceCustomer.Id, ContractId = contract.Id, DateCreate = DateTimeOffset.Now, CustomerRoleId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicCustomerRole), DicCustomerRole.Codes.Correspondence) }); _niisWebContext.SaveChanges(); } #endregion #region Добавление контрагентов foreach (var item in request.BlockCustomers) { if (item.CustomerType == null) { continue; } if (item.CustomerType.Id == 0) { item.CustomerType.Id = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicCustomerType), DicCustomerTypeCodes.Undefined); } var dicCustomer = new DicCustomer { TypeId = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerType), item.CustomerType.Id).Id, NameRu = item.NameRu, NameKz = item.NameKz, NameEn = item.NameEn, Phone = item.Phone, PhoneFax = item.Fax, Email = item.Email, Address = $"{item.Region}, {item.Street}, {item.Index}", CertificateNumber = item.CertificateNumber, CertificateSeries = item.CertificateSeries, Opf = item.Opf, ApplicantsInfo = item.ApplicantsInfo, PowerAttorneyFullNum = item.PowerAttorneyFullNum, ShortDocContent = item.ShortDocContent, Xin = item.Xin, NotaryName = item.NotaryName, DateCreate = DateTimeOffset.Now }; if (item.RegistrationDate != DateTime.MinValue) { dicCustomer.RegDate = new DateTimeOffset(item.RegistrationDate.GetValueOrDefault()); } var contractCustomer = new ContractCustomer { CustomerId = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(dicCustomer).Id, ContractId = contract.Id, DateCreate = DateTimeOffset.Now, CustomerRoleId = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerRole), item.CustomerRole.Id)?.Id }; _niisWebContext.ContractCustomers.Add(contractCustomer); _niisWebContext.SaveChanges(); } #endregion #region Добавление прикрепленного документа заявления var document = new Document(_dictionaryHelper.GetDocumentType(typeId).type) { TypeId = typeId, DateCreate = DateTimeOffset.Now, AddresseeId = addressee.Id, StatusId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDocumentStatus), DicDocumentStatusCodes.InWork), ReceiveTypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicReceiveType), DicReceiveTypeCodes.ElectronicFeed) }; _documentHelper.CreateDocument(document); _attachFileHelper.AttachFile(new AttachedFileModel { PageCount = request.RequisitionFile.PageCount.GetValueOrDefault(), CopyCount = request.RequisitionFile.CopyCount.GetValueOrDefault(), File = request.RequisitionFile.Content, Length = request.RequisitionFile.Content.Length, IsMain = true, Name = request.RequisitionFile.Name }, document); _niisWebContext.Documents.Update(document); _niisWebContext.SaveChanges(); _niisWebContext.ContractsDocuments.Add(new ContractDocument { DocumentId = document.Id, ContractId = contract.Id }); _niisWebContext.SaveChanges(); #endregion #region Добавление документов foreach (var attachedFile in request.AttachmentFiles) { if (attachedFile.File == null) { continue; } var documentType = _dictionaryHelper.GetDocumentType(attachedFile.FileType.Id); var inWorkStatusId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDocumentStatus), DicDocumentStatusCodes.InWork); var completedStatusId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDocumentStatus), DicDocumentStatusCodes.Completed); var attachmentDocument = new Document(documentType.type) { TypeId = documentType.typeId, DateCreate = DateTimeOffset.Now, StatusId = documentType.type == DocumentType.DocumentRequest ? completedStatusId : inWorkStatusId, AddresseeId = addressee.Id, ReceiveTypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicReceiveType), DicReceiveTypeCodes.ElectronicFeed) }; _documentHelper.CreateDocument(attachmentDocument); var attached = new AttachedFileModel { Length = attachedFile.File.Content.Length, PageCount = attachedFile.File.PageCount.GetValueOrDefault(), File = attachedFile.File?.Content, Name = attachedFile.File.Name, IsMain = true, CopyCount = 1 }; _attachFileHelper.AttachFile(attached, document); _niisWebContext.ContractsDocuments.Add(new ContractDocument { DocumentId = attachmentDocument.Id, ContractId = contract.Id }); _niisWebContext.SaveChanges(); } #endregion #region Добавление связи с ОД foreach (var contractPatent in request.PatentNumbers) { //Получаем типа патента if (!(_dictionaryHelper.GetDictionaryByExternalId(nameof(DicProtectionDocType), contractPatent.PatentType.Id) is DicProtectionDocType type)) { throw new NotSupportedException($"Тип с идентефикатором {contractPatent.PatentType.Id} не найден"); } var patentId = _niisWebContext .ProtectionDocs .Where(d => d.GosNumber == contractPatent.PatentNumber && d.Request.ProtectionDocTypeId == type.Id) .Select(d => d.Id).FirstOrDefault(); _niisWebContext.ContractProtectionDocRelations.Add(new ContractProtectionDocRelation { ProtectionDocId = patentId, ContractId = contract.Id }); _niisWebContext.SaveChanges(); } #endregion #region Добавление этапа обработки var routeId = _integrationDictionaryHelper.GetRouteIdByProtectionDocType(protectionDocTypeId); var stage = _integrationDictionaryHelper.GetRouteStage(routeId); var contractWorkflow = new ContractWorkflow { OwnerId = contract.Id, DateCreate = DateTimeOffset.Now, RouteId = routeId, CurrentStageId = stage.Id, CurrentUserId = _configuration.AuthorAttachmentDocumentId, IsComplete = stage.IsLast, IsSystem = stage.IsSystem, IsMain = stage.IsMain }; _niisWebContext.ContractWorkflows.Add(contractWorkflow); _niisWebContext.SaveChanges(); contract.CurrentWorkflowId = contractWorkflow.Id; _niisWebContext.Contracts.Update(contract); _niisWebContext.SaveChanges(); #endregion _integrationStatusUpdater.Add(contractWorkflow.Id); var onlineStatusId = 0; if (contractWorkflow.CurrentStageId != null) { onlineStatusId = _integrationDictionaryHelper.GetOnlineStatus(contractWorkflow.CurrentStageId.Value); } response.DocumentId = contract.Barcode; response.DocumentNumber = contract.IncomingNumber; response.RequisitionStatus = onlineStatusId; return(response); }
public ContractResponse GetAllotmentEventsContract() => ContractResponse.FromOptions(_nethereumOptions.AllotmentEventContract);
public ContractResponse GetERC223Contract() => ContractResponse.FromOptions(_nethereumOptions.ERC223Contract);
public ContractResponse GetSmartValleyTokenContract() => ContractResponse.FromOptions(_nethereumOptions.SmartValleyTokenContract);
public ContractResponse GetMinterContract() => ContractResponse.FromOptions(_nethereumOptions.MinterContract);
public ContractResponse GetScoringParametersProviderContract() => ContractResponse.FromOptions(_nethereumOptions.ScoringParametersProviderContract);
public ContractResponse GetAdminRegistryContract() => ContractResponse.FromOptions(_nethereumOptions.AdminRegistryContract);
public ContractResponse GetExpertsRegistryContract() => ContractResponse.FromOptions(_nethereumOptions.ExpertsRegistryContract);
public ContractResponse GetScoringContract() => ContractResponse.FromOptions(_nethereumOptions.ScoringContract);
public ContractResponse GetPrivateScoringManagerContract() => ContractResponse.FromOptions(_nethereumOptions.PrivateScoringManagerContract);