public void Add(CarViewModel carViewModel) { var newcar = new CarViewModel { Name = "New Car Happy Year" }; if (!IsCarValid(newcar)) { throw new ArgumentException("Car model is Invalid"); } var addcar = new CarModel { Name = newcar.Name, Details = new List <DetailModel> { new DetailModel { NameDetail = "Glass", Number = 1234, Price = 1500 } } }; _carsevice.Add(addcar); }
public TransactionHashInfo Post([FromBody] TransactionModel request) { if (!ShouldSendCoins(request.RecipientAddress)) { return(new TransactionHashInfo() { IsValid = false, ErrorMessage = "User has received coins in the last hour." }); } if (request.Value > _appSettings.MaxAddressDonationPerHour) { return(new TransactionHashInfo() { IsValid = false, ErrorMessage = String.Format("User cannot receive more than {0} coins per hour.", _appSettings.MaxAddressDonationPerHour) }); } var privateKey = CryptoUtils.HexToByteArray(_appSettings.PrivateKey); var publicKey = CryptoUtils.GetPublicFor(privateKey); var date = DateTime.UtcNow; TransactionData dataToSign = GetDataToSign(request, publicKey, date); var json = Newtonsoft.Json.JsonConvert.SerializeObject(dataToSign); var msgHash = CryptoUtils.GetSha256Bytes(json); var signedMessage = CryptoUtils.BouncyCastleSign(msgHash, privateKey); // send http request to node var signedTransactionData = new TransactionDataSigned { From = _appSettings.FaucetAddress, To = request.RecipientAddress, Value = request.Value, Fee = 0, SenderPubKey = CryptoUtils.ByteArrayToHex(publicKey), DateCreated = date, SenderSignature = CryptoUtils.ByteArrayToHex(signedMessage) }; var res = HttpUtils.DoApiPost <TransactionDataSigned, TransactionHashInfo>(request.NodeUrl, "api/transactions", signedTransactionData); if (res.IsValid) { // add transaction record with limits var recordHistory = new TransactionHistory { Address = request.RecipientAddress, DateReceived = res.DateReceived, Amount = request.Value }; _dbService.Add(request.RecipientAddress, recordHistory); } return(res); }
public void Add(DetailViewModel detailViewModel) { var detail = new DetailModel { NameDetail = "Engine", Price = 1280, CarId = 2, ManufacturerId = 2 }; _cardetailsservice.Add(detail); }