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; }
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(); }
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)); }
private void ValidateContractDto(ContractDto contractDto) { if (contractDto.IsSelfContract()) { throw new SelfContractException(); } if (this.ContractExists(contractDto)) { throw new DuplicateContractException(); } }
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()); }
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); }
// 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); }
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)); }
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 }); }
/// <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); }
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)); }
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()); }
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); }
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); }
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(); }
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); }
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)); }
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)); }
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)); }
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)); }
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; } }
/// <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); }
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>(); }
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)); }
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); } }
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); }
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()); }
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); }
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); } }
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."); }