コード例 #1
0
 public static void MapDtoToEntityForUpdating(ContractDto contractDto, Contract contract)
 {
     contract.IsActive                 = contractDto.IsActive;
     contract.ResourceId               = contractDto.ResourceId;
     contract.EmployeeId               = contractDto.EmployeeId;
     contract.WeeklyHours              = contractDto.WeeklyHours;
     contract.BaseRateOverride         = contractDto.BaseRateOverride;
     contract.OvertimeModifierOverride = contractDto.OvertimeModifierOverride;
     contract.StartDate                = contractDto.StartDate;
     contract.EndDate = contractDto.EndDate;
 }
コード例 #2
0
        public async Task DeleteContract(ContractDto contractDto)
        {
            if (!this.ContractExists(contractDto))
            {
                return;
            }

            var contract = this.Mapper.Map <Contract>(contractDto);

            this.context.Contracts.Remove(contract);
            await this.context.SaveChangesAsync();
        }
コード例 #3
0
        public async Task <IActionResult> GetContractById(string id)
        {
            int ID     = Convert.ToInt32(id);
            var entity = await ContractDto.ToEntity(ID, _context);

            if (entity == null)
            {
                return(NotFound());
            }

            return(Ok(entity));
        }
コード例 #4
0
        private void ValidateContractDto(ContractDto contractDto)
        {
            if (contractDto.IsSelfContract())
            {
                throw new SelfContractException();
            }

            if (this.ContractExists(contractDto))
            {
                throw new DuplicateContractException();
            }
        }
コード例 #5
0
        public async Task <IActionResult> Delete(int id)
        {
            var entity = await ContractDto.ToEntity(id, _context);

            if (entity == null)
            {
                return(NotFound());
            }
            _context.Contracts.Remove(entity);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #6
0
ファイル: Contract.cs プロジェクト: memi13/memiCarRent
        internal ContractDto ToDto()
        {
            var contractDto = new ContractDto();

            contractDto.id            = Id;
            contractDto.PublicId      = PublicId;
            contractDto.Description   = Description;
            contractDto.From          = From;
            contractDto.OnTil         = OnTill;
            contractDto.ReservationId = Reservation.Id;
            contractDto.CarId         = Car.Id;
            return(contractDto);
        }
コード例 #7
0
        // CRUD
        public void Create(ContractDto contractDto, long userId)
        {
            var contract = Mapper.Map <Contract>(contractDto);

            _unitOfWork.ContractRepository.Create(contract);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeCreate,
                AppConstants.ContractTableName,
                userId,
                contract.Id);
        }
コード例 #8
0
        public async Task <IActionResult> Put(ContractDto contractDto)
        {
            var entity = await ContractDto.ToEntity(contractDto, _context);

            if (entity == null)
            {
                return(NotFound());
            }

            _context.Entry(entity).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Get", new { }, contractDto));
        }
コード例 #9
0
ファイル: ConverterHelper .cs プロジェクト: lGodie/Leases
 public async Task <Contract> ToContractAsync(ContractDto model, bool isNew)
 {
     return(new Contract
     {
         EndDate = model.EndDate,
         IsActive = model.IsActive,
         Lessee = await _dataContext.Lessees.FindAsync(model.LesseeId),
         Owner = await _dataContext.Owners.FindAsync(model.OwnerId),
         Price = model.Price,
         Property = await _dataContext.Properties.FindAsync(model.PropertyId),
         Remarks = model.Remarks,
         StartDate = model.StartDate,
         Id = isNew ? 0 : model.Id
     });
 }
コード例 #10
0
ファイル: SmartContractService.cs プロジェクト: zhxymh/AElf
        /// <inheritdoc/>
        public Task DeployContractAsync(ContractDto contractDto)
        {
            // get runner
            var runner = _smartContractRunnerContainer.GetRunner(contractDto.SmartContractRegistration.Category);

            if (contractDto.ContractName != null)
            {
                _smartContractAddressService.SetAddress(contractDto.ContractName, contractDto.ContractAddress);
            }
            //Todo New version metadata handle it
//            var contractType = runner.GetContractType(registration);
//            var contractTemplate = runner.ExtractMetadata(contractType);
//            await _functionMetadataService.DeployContract(contractAddress, contractTemplate);
            return(Task.CompletedTask);
        }
コード例 #11
0
ファイル: OwnersController .cs プロジェクト: lGodie/Leases
      public async Task <IActionResult> EditContract(ContractDto model)
      {
          if (ModelState.IsValid)
          {
              var contract = await _converterHelper.ToContractAsync(model, false);

              _dataContext.Contracts.Update(contract);
              await _dataContext.SaveChangesAsync();

              return(RedirectToAction($"{nameof(DetailsProperty)}/{model.PropertyId}"));
          }

          model.Lessees = _combosHelper.GetComboLessees();
          return(View(model));
      }
コード例 #12
0
        public async Task <IActionResult> Post([FromBody] ContractDto contract, CancellationToken cancellationToken)
        {
            var request  = _requestClient.Create(contract, cancellationToken);
            var response = await request.GetResponse <IOperationResult <OperationStatus> >();

            var result = response.Message.Data;
            await _hubContext.Clients.All.SendAsync("ContractProcessed", result.Message);

            if (result.Success)
            {
                return(Ok());
            }

            return(BadRequest());
        }
コード例 #13
0
        public async Task CreateCommentAsync()
        {
            ContractDto contractdto = new ContractDto()
            {
                ClientId         = "seedone",
                Date             = new DateTimeOffset(2021, 2, 5, 12, 30, 30, new TimeSpan(1, 0, 0)).AddDays(-2),
                FeePercentage    = 0.28,
                IsPaid           = false,
                IsSigned         = false,
                PaymentFrequency = 2,
                PaymentMethod    = PaymentMethod.BankTransfer,
                PropertyId       = 10
            };

            var result = await _service.CreateAsync(contractdto);
        }
コード例 #14
0
        public void Update(ContractDto contractDto, long userId)
        {
            var contract = _unitOfWork.ContractRepository.GetById(contractDto.Id);

            CommonHelperAppService.MapDtoToEntityForUpdating(contractDto, contract);

            _unitOfWork.ContractRepository.Update(contract);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeUpdate,
                AppConstants.ContractTableName,
                userId,
                contract.Id);
        }
コード例 #15
0
        public void CreateContract_SelfContractExceptionThrown_ExceptionThrown()
        {
            // Arrange
            var contractorId = this.Fixture.Create <int>();
            var contract     = new ContractDto {
                Contractor1Id = contractorId, Contractor2Id = contractorId
            };

            this.contractServiceMock.Setup(x => x.CreateContract(contract)).Throws(new SelfContractException());

            // Act
            Should.ThrowAsync <SelfContractException>(this.sut.CreateContract(contract));

            // Assert
            this.contractServiceMock.VerifyAll();
        }
コード例 #16
0
ファイル: SmartContractService.cs プロジェクト: zhxymh/AElf
        public Task UpdateContractAsync(ContractDto contractDto)
        {
            // get runner
            var runner = _smartContractRunnerContainer.GetRunner(contractDto.SmartContractRegistration.Category);

            //Todo New version metadata handle it
//            var oldRegistration = await GetContractByAddressAsync(contractAddress);
//            var oldContractType = runner.GetContractType(oldRegistration);
//            var oldContractTemplate = runner.ExtractMetadata(oldContractType);
//
//            var newContractType = runner.GetContractType(newRegistration);
//            var newContractTemplate = runner.ExtractMetadata(newContractType);
//            await _functionMetadataService.UpdateContract(contractAddress, newContractTemplate,
//                oldContractTemplate);
            return(Task.CompletedTask);
        }
コード例 #17
0
        public async Task <PropertyDto> SaveData(int property, ContractDto contract)
        {
            var propertyDto = await this.propertyRepository.FindAsync(property);

            var owner  = propertyDto.Owner;
            var lessee = await lesseeRepository.FindById(contract.Lessee.Id);

            contract.Owner        = owner;
            contract.Lessee       = lessee;
            propertyDto.Contracts = propertyDto.Contracts ?? new List <ContractDto>();
            propertyDto.Contracts.Add(contract);
            dataContext.Properties.Update(propertyDto);
            dataContext.Entry(propertyDto).State = EntityState.Modified;
            await dataContext.SaveChangesAsync();

            return(await propertyRepository.FindById(property));
        }
コード例 #18
0
        public ActionResult Post([FromBody] ContractDto contractModel)
        {
            _logger.LogInformation($"[ContractController] - Post method started at {DateTime.Now}.");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var contract = _mapper.Map <Contract>(contractModel);

            _contractRepository.AddContract(contract);

            var key = contract.ContractNr.Replace(" ", "-").ToLower();

            return(Created("api/contract/" + key, null));
        }
コード例 #19
0
        public async Task <ActionResult <ContractDto> > Post(ContractDto dto)
        {
            var entity = await ContractDto.ToEntity(dto, _context);

            if (entity == null)
            {
                return(NotFound());
            }

            await _context.Contracts.AddAsync(entity);

            await _context.SaveChangesAsync();

            var contractDto = ContractDto.FromEntity(entity);

            return(CreatedAtAction("Get", new { }, contractDto));
        }
コード例 #20
0
        public ActionResult Add()
        {
            var helperBo = new HelperBo();
            // tìm danh sách khách hàng
            var listCustomers = helperBo.SelectWhere(null, "customer", null, null);
            var list          = new List <CustomerDto>();

            if (listCustomers.success && listCustomers.data.Count > 0)
            {
                // tìm tích kê theo của từng khách hàng
                var curDate = DateUtils.FormatYYYYMMDD(DateTime.Now.ToShortDateString());
                foreach (var customer in listCustomers.data)
                {
                    var c = new CustomerDto();
                    c.ID           = customer.ID;
                    c.NAME         = customer.NAME;
                    c.NUMBER_PHONE = customer.NUMBER_PHONE;
                    c.TYPE         = customer.TYPE;
                    c.AGE          = customer.AGE.ToString();
                    c.ADDRESS      = customer.ADDRESS;

                    var listTichKe = helperBo.SelectWhere(null, "contract", "DATE>='" + curDate + "' and CUSTOMER_ID=" + customer.ID, null);
                    if (listTichKe.success && listTichKe.data.Count > 0)
                    {
                        List <ContractDto> listContract = new List <ContractDto>();
                        foreach (var contract in listTichKe.data)
                        {
                            var Contract = new ContractDto()
                            {
                                CUSTOMER_ID = contract.CUSTOMER_ID,
                                DATE        = contract.DATE,
                                ID          = contract.ID,
                                PRODUCT_ID  = contract.PRODUCT_ID,
                                RATIO       = contract.RATIO,
                                TYPE        = contract.TYPE
                            };
                            listContract.Add(Contract);
                        }
                        c.SetList(listContract);
                        list.Add(c);
                    }
                }
            }
            return(View(list));
        }
コード例 #21
0
        public int PostContract(ContractDto contract)
        {
            try
            {
                var depouille = _context.Depouillement.Find(contract.depouilleId);
                depouille.contract = new Contract(contract.code, contract.name, contract.dateContract, contract.payment);

                _context.SaveChanges();

                int?Id = _context.Contract.Where(c => c.depouilleId == contract.depouilleId).FirstOrDefault().Id;

                return((int)Id);
            } catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
コード例 #22
0
        /// <inheritdoc/>
        public async Task DeployContractAsync(ContractDto contractDto)
        {
            // get runner
            var runner = _smartContractRunnerContainer.GetRunner(contractDto.SmartContractRegistration.Category);
            await Task.Run(() => runner.CodeCheck(contractDto.SmartContractRegistration.Code.ToByteArray(), contractDto.IsPrivileged));

            if (contractDto.ContractName != null)
            {
                _smartContractAddressService.SetAddress(contractDto.ContractName, contractDto.ContractAddress);
            }
            await _smartContractExecutiveService.SetContractInfoAsync(contractDto.ContractAddress,
                                                                      contractDto.BlockHeight);

            //Todo New version metadata handle it
//            var contractType = runner.GetContractType(registration);
//            var contractTemplate = runner.ExtractMetadata(contractType);
//            await _functionMetadataService.DeployContract(contractAddress, contractTemplate);
        }
コード例 #23
0
        public void Create_notfoundproperty()
        {
            ContractDto contractdto = new ContractDto()
            {
                ClientId         = "seedone",
                Date             = new DateTimeOffset(2021, 2, 5, 12, 30, 30, new TimeSpan(1, 0, 0)).AddDays(-2),
                FeePercentage    = 0.28,
                IsPaid           = false,
                IsSigned         = false,
                PaymentFrequency = 2,
                PaymentMethod    = PaymentMethod.BankTransfer,
                PropertyId       = 3
            };

            Func <Task> action = async() => await _service.CreateAsync(contractdto);

            action.Should().Throw <InvalidQueryParamsException>();
        }
コード例 #24
0
        public IActionResult Get(int id)
        {
            DateTime curDate  = DateTime.Now;
            var      contract = _contractRepo.GetContract(1);

            Expression <Func <IPeriodEntity, bool> > predicate = bo2Elo => bo2Elo.SDate <= curDate && (bo2Elo.EDate == null || bo2Elo.EDate > curDate);

            var result = new ContractDto
            {
                SubContracts = contract.SubContracts.Select(sc => new SubContractDto {
                    Id = sc.Id, Name = sc.DocumentNumber, SDate = sc.SignDate
                }).ToList(),
                Side1       = contract.ContractParticipants.Where(cp => cp.ParticipantType == Domain.Enums.ParticipantType.Supplier).FirstOrDefault()?.Organization?.ShortName,
                Side2       = contract.ContractParticipants.Where(cp => cp.ParticipantType == Domain.Enums.ParticipantType.Customer).FirstOrDefault()?.Organization?.ShortName,
                BillObjects = contract.BillObjects.Select(bo => new BillObjectDto
                {
                    Id   = bo.Id,
                    Name = bo.Name,
                    EnergyLinkObjects = bo.BillObjectsToEnergyLinkObjects
                                        .Where(bo2Elo => /*true || */ bo2Elo.SDate <= curDate && (bo2Elo.EDate == null || bo2Elo.EDate > curDate))
                                        .Select(elo => new EnergyLinkObjectDto
                    {
                        Id         = elo.EnergyLinkObjectId,
                        Name       = elo.EnergyLinkObject.Name,
                        BillPoints = elo.EnergyLinkObject.EnergyLinkObjectsToBillPoints
                                     .Where(bo2Elo => /*true || */ bo2Elo.SDate <= curDate && (bo2Elo.EDate == null || bo2Elo.EDate > curDate))
                                     .Select(bp => new BillPointDto {
                            Id         = bp.BillPoint.Id, Name = bp.BillPoint.Name,
                            BillParams = bp.BillParams.Select(bparam => new BillParamDto {
                                Value = bparam.Value, Id = (int)bparam.BillParamType
                            }).ToList()
                        })
                                     .ToList()
                    }).ToList()
                }).ToList()
            };

            /*
             * var boToElo = contract.BillObjects
             *  .SelectMany(bo => bo.BillObjectsToEnergyLinkObjects)
             *  .Where(bo2Elo => bo2Elo.SDate <= curDate && (bo2Elo.EDate == null || bo2Elo.EDate > curDate));
             */
            return(Ok(result));
        }
コード例 #25
0
        public static ContractDetailsDto GetContractDetails(ContractDto contractDto)
        {
            using (var context = new PawnShopContext())
            {
                context.Users.Attach(LoginUser.User);
                var employee = context.Contracts.Find(contractDto.ContractId).Employee.Credentials.Email;

                var contractDetails = new ContractDetailsDto()
                {
                    Id                 = contractDto.ContractId,
                    Date               = contractDto.DateOfRegistrationAndExpiring,
                    Property           = contractDto.PledgedProperty,
                    ProperyValue       = contractDto.PropertyValue.ToString(),
                    ValueAfterInterest = (contractDto.PropertyValue * contractDto.Interest + contractDto.PropertyValue).ToString()
                };

                return(contractDetails);
            }
        }
コード例 #26
0
        public ContractDto GetById(string contractId)
        {
            var contractDto = new ContractDto();

            if (contractId == "CONTRACTID")
            {
                contractDto.ExpirationDate = DateTime.Now.AddDays(1);
            }
            else if (contractId == "EXPIREDCONTRACTID")
            {
                contractDto.ExpirationDate = DateTime.Now.AddDays(-1);
            }
            // stubbed... ultimately, it will go out to the
            // database and retrieve the given contract
            // record based on contractId

            contractDto.ContractId = contractId;
            return(contractDto);
        }
コード例 #27
0
        public ActionResult Put(string contractNumber, [FromBody] ContractDto contractModel)
        {
            _logger.LogInformation($"[ContractController] - Put method started at {DateTime.Now}.");

            var contract = _contractRepository.GetContractById(contractNumber);

            if (contract == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _contractRepository.EditContract(contract, contractModel);

            return(NoContent());
        }
コード例 #28
0
        public async Task UpdateContractAsync(ContractDto contractDto)
        {
            // get runner
            var runner = _smartContractRunnerContainer.GetRunner(contractDto.SmartContractRegistration.Category);
            await Task.Run(() => runner.CodeCheck(contractDto.SmartContractRegistration.Code.ToByteArray(),
                                                  contractDto.IsPrivileged));

            await _smartContractExecutiveService.SetContractInfoAsync(contractDto.ContractAddress,
                                                                      contractDto.BlockHeight);

            //Todo New version metadata handle it
//            var oldRegistration = await GetContractByAddressAsync(contractAddress);
//            var oldContractType = runner.GetContractType(oldRegistration);
//            var oldContractTemplate = runner.ExtractMetadata(oldContractType);
//
//            var newContractType = runner.GetContractType(newRegistration);
//            var newContractTemplate = runner.ExtractMetadata(newContractType);
//            await _functionMetadataService.UpdateContract(contractAddress, newContractTemplate,
//                oldContractTemplate);
        }
コード例 #29
0
        public static ContractDto GetContractById(int contractId)
        {
            using (var context = new PawnShopContext())
            {
                var contract    = context.Contracts.Find(contractId);
                var contractDto = new ContractDto()
                {
                    ContractId = contract.Id,
                    Client     = contract.Client.FirstName + " " + contract.Client.MiddleName + " " + contract.Client.LastName + Environment.NewLine + contract.Client.PersonalID,
                    DateOfRegistrationAndExpiring =
                        contract.StartDate.Date.ToString() + " - " + contract.EndDate.Date.ToString(),
                    PropertyValue   = contract.PropertyValue,
                    Interest        = contract.Interest,
                    Days            = (contract.StartDate - contract.EndDate).Days,
                    PledgedProperty = contract.PledgedProperty,
                    Status          = contract.Status
                };

                return(contractDto);
            }
        }
コード例 #30
0
        public void Create_soldpropertyfailed()
        {
            var property = _context.Properties.Where(c => c.Id == 3).FirstOrDefault();

            property.Sold = true;
            ContractDto contractdto = new ContractDto()
            {
                ClientId         = "seedone",
                Date             = new DateTimeOffset(2021, 2, 5, 12, 30, 30, new TimeSpan(1, 0, 0)).AddDays(-2),
                FeePercentage    = 0.28,
                IsPaid           = false,
                IsSigned         = false,
                PaymentFrequency = 2,
                PaymentMethod    = PaymentMethod.BankTransfer,
                PropertyId       = 3
            };

            Func <Task> action = async() => await _service.CreateAsync(contractdto);

            action.Should().Throw <InvalidQueryParamsException>().WithMessage("Hibás paraméterek.");
        }