AzureLens.Controllers.DiagramsController.ShareAsync C# (CSharp) Method

ShareAsync() private method

private ShareAsync ( System.Guid id ) : Task
id System.Guid
return Task
        public async Task<string> ShareAsync(Guid id)
        {
            dynamic diagram;
            diagram = await DAL.LoadDiagram(id);
            var user = UserHelper.GetCurrentUserID();
            if (diagram.userId != user)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.Unauthorized)
                {
                    Content = new StringContent("User not authorized to share this diagram"),
                    ReasonPhrase = "User not authorized to share this diagram"
                };
                throw new HttpResponseException(resp);
            }


            var hash = await DAL.GenerateHashAsync(id);
            if (string.IsNullOrEmpty(hash))
            {
                throw new HttpResponseException(System.Net.HttpStatusCode.Gone);
            }
            var baseUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority);
            var shareUrl = string.Format("{0}",  hash);
            return shareUrl;
        }