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

UpdateDiagramAsync() private method

private UpdateDiagramAsync ( [ diagram ) : Task
diagram [
return Task
        public async Task<string> UpdateDiagramAsync([FromBody]JToken diagram)
        {
            dynamic existingDiagram;
            string id = GetDiagramId(diagram);
            if (id == null)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotAcceptable)
                {
                    Content = new StringContent("DiagramId (id) not found in diagram"),
                    ReasonPhrase = "Invalid diagram object for Update"
                };
                throw new HttpResponseException(resp);
            }
            existingDiagram = await DAL.LoadDiagram(Guid.Parse(id));

            var x = diagram.Value<string>("userId");
            var user = UserHelper.GetCurrentUserID();
            if (existingDiagram.userId != user )
            {
                var resp = new HttpResponseMessage(HttpStatusCode.Unauthorized)
                {
                    Content = new StringContent("User not authorized to save this diagram"),
                    ReasonPhrase = "User not authorized to save this diagram"
                };
                throw new HttpResponseException(resp);
            }

            if (diagram["userId"] == null || string.IsNullOrWhiteSpace(diagram["userId"].Value<string>()))
            {
                diagram["userId"] = user.ToLowerInvariant();
            }
            diagram["lastUpdated"] = System.DateTime.Now;
            var diagramStr = diagram.ToString();
            return await DAL.UpdateDiagramAsync(diagramStr);
        }