public void AssetNameLenth_CantBeLessThan5() { Assert.ThrowsAsync <ValidationException>(() => { return(assetService.CreateAsset(new Asset { AssetName = "1234" })); }); }
public JsonResult Save(AssetViewModel assetViewModel) { if (assetViewModel.Id <= 0) { assetViewModel.AssetStatus = Core.Enums.AssetStatus.New; } assetService.CreateAsset(assetViewModel); return(Json(new { Type = "success", Message = "Asset Saved Successfully" }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult <Asset> > Post([FromBody] Asset asset) { await _assetService.CreateAsset(asset); return(CreatedAtAction( "Get", new { id = asset.ID }, asset )); }
public HttpResponseMessage CreateAsset([FromBody] AssetDTO assetDTO) { int newID = _assetService.CreateAsset(assetDTO); string uri = Url.Link("AssetByIDRoute", new { id = newID }); // Generate a link to the new campus and set the location header in the response. var response = new HttpResponseMessage(HttpStatusCode.Created); response.Headers.Location = new System.Uri(uri); return(response); }
public async Task <AssetModel> Handle(CreateAssetCommand request, CancellationToken cancellationToken) { System.Enum.TryParse(request.Department, out Department department); var asset = new Asset { AssetName = request.AssetName, Broken = request.Broken, CountryOfDepartment = request.CountryOfDepartment, Department = department, EMailAddressOfDepartment = request.EMailAddressOfDepartment, PurchaseDate = request.PurchaseDate }; await assetService.CreateAsset(asset); return(mapper.Map <AssetModel>(asset)); }
public async Task <IActionResult> Post([FromBody] AssetModel model) { try { var userId = User.Identity.Name; if (userId != null) { model.CreateUserId = Guid.Parse(userId); model.CreateDate = DateTime.Now; model.ModifyUserId = Guid.Parse(userId); model.ModifyDate = DateTime.Now; return(Ok(_assetService.CreateAsset(model))); } return(BadRequest("An error has occurred, please contact system administrator!")); } catch (Exception e) { throw new Exception(e.Message); } }
public virtual async Task <IActionResult> PostCreateAsset([FromBody] CreateAssetCreateOrUpdate body) { var res = await _assetService.CreateAsset(body.Issuer, body.Symbol, body.Precision, body.AssetOption, body.BitassetOption, body.Broadcast); return(new ObjectResult(res)); }
public async Task <IActionResult> CreateAsset(AssetDto assetDto) { var assetReturn = await _assetService.CreateAsset(assetDto); return(CreatedAtRoute("GetAsset", new { Controller = "Asset", id = assetReturn.ID }, assetReturn)); }