protected void ButtonSave_Click(object sender, EventArgs e) { if (FileUploadImage.HasFiles & Page.IsValid) { string uniqueBobName = string.Format("{0}/funnyimage_{1}{2}", Utils.CloudBlobKey, Guid.NewGuid().ToString(), Path.GetExtension(FileUploadImage.FileName)); CloudBlockBlob blob = _blobClient.GetBlockBlobReference(uniqueBobName); blob.Properties.ContentType = FileUploadImage.PostedFile.ContentType; blob.UploadFromStream(FileUploadImage.FileContent); FunnyAppRepository<Post> postRepository = new FunnyAppRepository<Post>(); FunnyAppRepository<Tag> tagRepository = new FunnyAppRepository<Tag>(); MembershipUser user = Membership.GetUser(Page.User.Identity.Name); if (user != null) { Post post = new Post { PostContent = TextBoxDescription.Text, PostTitle = TextBoxTitle.Text, State = false, UserId = user.ProviderUserKey.ToString() }; string[] tags = TextBoxTag.Text.Split(';'); foreach (string tag in tags) { if (!string.IsNullOrEmpty(tag)) { tagRepository.Create(new Tag() { PostRowKey = post.RowKey, PostPartitionKey = post.PartitionKey, TagName = tag, }); tagRepository.SubmitChange(); } } postRepository.Create(post); postRepository.SubmitChange(); CloudQueue queue = _queueClient.GetQueueReference(Utils.CloudQueueKey); CloudQueueMessage message = new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri, post.PartitionKey, post.RowKey)); queue.AddMessage(message); LabelResult.Text = "Uploaded"; } else { LabelResult.Text = "Failed"; } } }
protected void ButtonSave_Click(object sender, EventArgs e) { if (FileUploadImage.HasFiles & Page.IsValid) { string uniqueBobName = string.Format("{0}/funnyimage_{1}{2}", Utils.CloudBlobKey, Guid.NewGuid().ToString(), Path.GetExtension(FileUploadImage.FileName)); CloudBlockBlob blob = _blobClient.GetBlockBlobReference(uniqueBobName); blob.Properties.ContentType = FileUploadImage.PostedFile.ContentType; blob.UploadFromStream(FileUploadImage.FileContent); FunnyAppRepository <Post> postRepository = new FunnyAppRepository <Post>(); FunnyAppRepository <Tag> tagRepository = new FunnyAppRepository <Tag>(); MembershipUser user = Membership.GetUser(Page.User.Identity.Name); if (user != null) { Post post = new Post { PostContent = TextBoxDescription.Text, PostTitle = TextBoxTitle.Text, State = false, UserId = user.ProviderUserKey.ToString() }; string[] tags = TextBoxTag.Text.Split(';'); foreach (string tag in tags) { if (!string.IsNullOrEmpty(tag)) { tagRepository.Create(new Tag() { PostRowKey = post.RowKey, PostPartitionKey = post.PartitionKey, TagName = tag, }); tagRepository.SubmitChange(); } } postRepository.Create(post); postRepository.SubmitChange(); CloudQueue queue = _queueClient.GetQueueReference(Utils.CloudQueueKey); CloudQueueMessage message = new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri, post.PartitionKey, post.RowKey)); queue.AddMessage(message); LabelResult.Text = "Uploaded"; } else { LabelResult.Text = "Failed"; } } }
protected void ButtonCommentSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { _commentRepository.Create(new Comment() { Content = TextBoxCommet.Text, UserName = TextBoxUserName.Text, UserEmail = TextBoxEmail.Text, PostRowKey = HiddenFieldPost.Value }); _commentRepository.SubmitChange(); LabelResult.Text = "Comment Sended"; } else { LabelResult.Text = "Comment Failed"; } }