Beispiel #1
0
        public ActionResult CreateAsset(int id)
        {
            switch (isAuthorized(id))
            {
            case AuthState.NoAuth:
                return(View("NotAuthorized"));

            default:
                var model = new CreateAssetModel()
                {
                    customerassetlist = dbAsset.ReadAllWithFk(id),
                    Users             = dbUser.ReadAllWithFk(id),
                    customerId        = id,
                    Customers         = new List <Customer>()
                    {
                        db.Read(id)
                    },
                    Manufacturers = dbManufacturer.ReadAll(),
                    AssetTypes    = dbAssetType.ReadAll(),
                    Asset         = new Asset()
                    {
                        InstallationDate = DateTime.Now
                    }
                };
                ports = new List <Port>();

                return(View(model));
            }
        }
        public async Task <IActionResult> CreateCoinAdapter([FromBody] CreateAssetModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ICoin asset = new Coin()
            {
                ExternalTokenAddress     = model.ExternalTokenAddress,
                ContainsEth              = model.ContainsEth,
                Blockchain               = model.Blockchain,
                BlockchainDepositEnabled = true,
                Id         = Guid.NewGuid().ToString(),
                Multiplier = model.Multiplier,
                Name       = model.Name,
            };

            string contractAddress = await _assetContractService.CreateCoinContract(asset);

            return(Ok(new RegisterResponse
            {
                Contract = contractAddress
            }));
        }
Beispiel #3
0
        // GET: Assets/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var asset = db.Read(id.Value);

            if (isAuthorized(asset.Customer.Id) == AuthState.NoAuth)
            {
                return(View("NotAuthorized"));
            }
            var model = new CreateAssetModel()
            {
                Asset      = asset,
                AssetTypes = dba.ReadAll(),
                Customers  = new List <Customer>()
                {
                    dbc.Read(asset.Customer.Id)
                }
            };

            if (model.Asset == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
        public HttpResponseMessage CreateAsset(CreateAssetModel model)
        {
            var asset = new WAMSAssetModel();

            try
            {
                asset = _wamsProvider.CreateWAMSAsset(_wamsProvider.SanitizeFileName(model.FileName));
            }
            catch (Exception e)
            {
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, new { errorMessage = e.Message }));
            }
            return(this.Request.CreateResponse(HttpStatusCode.OK, new { asset }));
        }
Beispiel #5
0
        public ActionResult CreateAsset(Asset asset, HttpPostedFileBase upload, string atInput, string atInputManu)
        {
            switch (isAuthorized(asset.Customer.Id))
            {
            case AuthState.NoAuth:
                return(View("NotAuthorized"));

            default:
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(atInput))
                    {
                        var type = dbAssetType.Create(new AssetType
                        {
                            Description = atInput
                        });

                        asset.Type   = type;
                        asset.TypeId = type.Id;
                    }
                    else
                    {
                        asset.TypeId = asset.Type.Id;
                        asset.Type   = dbAssetType.Read(asset.Type.Id);
                    }
                    if (!string.IsNullOrEmpty(atInputManu))
                    {
                        var manu = dbManufacturer.Create(new Manufacturer
                        {
                            manufacturer = atInputManu
                        });
                        asset.Manufacturer   = manu;
                        asset.ManufacturerId = manu.Id;
                    }
                    else
                    {
                        asset.Manufacturer   = dbManufacturer.Read(asset.Manufacturer.Id);
                        asset.ManufacturerId = asset.Manufacturer.Id;
                    }

                    var sw = new Switch();

                    if (upload != null && upload.ContentLength > 0)
                    {
                        var attachment = new File()
                        {
                            ContentType = upload.ContentType,
                            ContentFile = new ContentFile(),
                            Name        = System.IO.Path.GetFileName(upload.FileName),
                        };

                        using (var reader = new System.IO.BinaryReader(upload.InputStream))
                        {
                            attachment.ContentFile.Content = reader.ReadBytes(upload.ContentLength);
                        }
                        asset.FileAttachments = new List <File>()
                        {
                            attachment
                        };
                    }

                    var a = dbAsset.Create(asset);

                    var aa = dbAsset.Read(a.Id);

                    foreach (var port in ports)
                    {
                        port.SwitchId = aa.Switch.Id;
                        port.Switch   = null;
                        port.Asset    = null;
                        dbPort.Create(port);
                    }

                    ports = new List <Port>();

                    return(RedirectToAction("Details", new { id = asset.Customer.Id }));
                }


                //FAILED
                var model = new CreateAssetModel()
                {
                    Users     = dbUser.ReadAll(),
                    Customers = new List <Customer>()
                    {
                        db.Read(asset.Customer.Id)
                    },
                    AssetTypes    = dbAssetType.ReadAll(),
                    Manufacturers = dbManufacturer.ReadAll(),
                    Asset         = asset
                };


                return(View(model));
            }
        }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <RegisterResponse> ApiCoinAdapterCreatePostAsync(this IEthereumApi operations, CreateAssetModel model = default(CreateAssetModel), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ApiCoinAdapterCreatePostWithHttpMessagesAsync(model, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 public static RegisterResponse ApiCoinAdapterCreatePost(this IEthereumApi operations, CreateAssetModel model = default(CreateAssetModel))
 {
     return(operations.ApiCoinAdapterCreatePostAsync(model).GetAwaiter().GetResult());
 }