Пример #1
0
        public async Task <IActionResult> Post([FromBody] Asset request)
        {
            try
            {
                var asset = repository.Find(null, d => d.Name.ToLower(null) == request.Name.ToLower(null))?.Items?.FirstOrDefault();
                if (asset != null)
                {
                    ModelState.AddModelError("Asset", "Asset Name Already Exists");
                    return(BadRequest(ModelState));
                }

                request = manager.GetSizeInBytes(request);

                var response = await base.PostEntity(request);

                await webhookPublisher.PublishAsync("Assets.NewAssetCreated", request.Id.ToString(), request.Name).ConfigureAwait(false);

                return(response);
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }