public async Task <ActionResult> Post(int instanceOwnerId, string applicationId) { if (string.IsNullOrEmpty(applicationId) || instanceOwnerId == 0) { return(BadRequest("Missing parameter values: applicationId and instanceOwnerId must be set")); } DateTime creationTime = DateTime.UtcNow; string applicationOwnerId = GetApplicationOwner(applicationId); Instance instance = new Instance() { InstanceOwnerId = instanceOwnerId.ToString(), CreatedBy = 0, CreatedDateTime = creationTime, LastChangedBy = 0, LastChangedDateTime = creationTime, ApplicationId = applicationId, ApplicationOwnerId = applicationOwnerId, }; string result = await _instanceRepository.InsertInstanceIntoCollectionAsync(instance); if (result == null) { return(BadRequest("Unable to write new instance to database")); } return(Ok(result)); }
public async Task <ActionResult> Post(int instanceOwnerId, string applicationId) { if (string.IsNullOrEmpty(applicationId) || instanceOwnerId == 0) { return(BadRequest("Both applicationId and instanceownerid must be set")); } DateTime creationTime = DateTime.UtcNow; Instance instance = new Instance() { InstanceOwnerId = instanceOwnerId.ToString(), CreatedBy = 0, CreatedDateTime = creationTime, LastChangedBy = 0, LastChangedDateTime = creationTime, ApplicationId = applicationId, }; string result = await _instanceRepository.InsertInstanceIntoCollectionAsync(instance); if (result == null) { return(BadRequest()); } return(Ok(result)); }
public async Task <ActionResult> Post(int instanceOwnerId, string applicationId) { if (string.IsNullOrEmpty(applicationId) || instanceOwnerId == 0) { return(BadRequest("Missing parameter values: applicationId and instanceOwnerId must be set")); } // check if metadata exists ApplicationMetadata appInfo = GetApplicationInformation(applicationId); if (appInfo == null) { return(Forbid($"Application Metadata is not registered for this applicationId: {applicationId}")); } DateTime creationTime = DateTime.UtcNow; string applicationOwnerId = appInfo.ApplicationOwnerId; Instance instance = new Instance() { InstanceOwnerId = instanceOwnerId.ToString(), CreatedBy = User.Identity.Name, CreatedDateTime = creationTime, LastChangedBy = User.Identity.Name, LastChangedDateTime = creationTime, ApplicationId = applicationId, ApplicationOwnerId = applicationOwnerId, VisibleDateTime = creationTime, }; string result = await _instanceRepository.InsertInstanceIntoCollectionAsync(instance); if (result == null) { logger.LogError("Unable to write new instance to database"); return(BadRequest("Unable to write new instance to database")); } return(Ok(result)); }