public async Task <IActionResult> CreateTagLinkAsync([FromBody] TagLinkModel model, [FromRoute] string lockid) { if (!Guid.TryParse(lockid, out var id)) { return(BadRequest(new ErrorResponse { Error = "Invalid lock id" })); } var userId = _identityService.GetUserIdentity(); var lockExists = await _locksService.CheckLockExistence(id, userId).ConfigureAwait(false); if (!lockExists) { return(UnprocessableEntity(new ErrorResponse { Error = "Lock does not exist" })); } var tagExists = await _locksTagsService.CheckTagExistence(model.TagId, userId).ConfigureAwait(false); if (!tagExists) { return(UnprocessableEntity(new ErrorResponse { Error = "Tag does not exist" })); } var toCreate = new LockTag { CreatedDate = DateTime.UtcNow, Id = Guid.NewGuid(), LockId = id, TagId = model.TagId }; var link = await _locksTagsService.CreateLink(toCreate, userId).ConfigureAwait(false); if (link == null) { return(Conflict(new ErrorResponse { Error = "Link already exists" })); } return(StatusCode((int)HttpStatusCode.Created)); }