public PdfAssembler(Discussion discussion, Topic topic, Person person, string PdfPathName) { this._discussion = discussion; this._topic = topic; this._PdfPathName = PdfPathName; this._person = person; }
public ReportingActivitiesTasks StartReportingActivities(Topic topic, Discussion disc, Session session, DiscCtx ctx) { _topic = topic; _disc = disc; _session = session; var moder = ctx.Person.Single(p => p.Name.StartsWith("moder")); _clienRt = new ClientRT(disc.Id, ConfigManager.ServiceServer, moder.Name, moder.Id, DeviceType.Wpf); _clienRt.onJoin += OnJoined; _hardReportTCS = new TaskCompletionSource<ReportCollector>(); _remoteScreenshotTCS = new TaskCompletionSource<Dictionary<int, byte[]>>(); Task.Factory.StartNew(async () => { while (_servicingPhotonClient) { _clienRt.Service(); await Utils.Delay(40); } }); return new ReportingActivitiesTasks { ReportTask = _hardReportTCS.Task, ScreenshotsTask = _remoteScreenshotTCS.Task }; }
StartReportingActivities(Topic topic, Discussion disc, Session session) { _topic = topic; _disc = disc; _session = session; var moder = DbCtx.Get().Person.Single(p => p.Name.StartsWith("moder")); _clienRt = new ClientRT(disc.Id, ConfigManager.ServiceServer, moder.Name, moder.Id, DeviceType.Wpf); _clienRt.onJoin += OnJoined; _hardReportTCS = new TaskCompletionSource<ReportCollector>(); _remoteScreenshotTCS = new TaskCompletionSource<Dictionary<int, byte[]>>(); Task.Factory.StartNew(async () => { while (_servicingPhotonClient) { _clienRt.Service(); await Utils.Delay(80); } }, TaskCreationOptions.LongRunning); return new Tuple<Task<Dictionary<int, byte[]>>, Task<ReportCollector>>( _remoteScreenshotTCS.Task, _hardReportTCS.Task); }
public void Generate(Discussion discussion, string PdfPathName) { this.discussion = discussion; this.PdfPathName = PdfPathName; document = new Document(); // we create a writer that listens to the document // and directs a PDF-stream to a file try { PdfWriter.GetInstance(document, new FileStream(PdfPathName, FileMode.Create)); } catch (Exception e) { MessageDlg.Show("File I/O error " + e.Message); return; } document.Open(); Assemble(); document.Close(); Process.Start(PdfPathName); }
public static void DeleteDiscussion(Discussion d) { if (!Ctors.DiscussionExists(d)) return; var ctx = PublicBoardCtx.Get(); //delete attachments var attachments = new List<Attachment>(); foreach (var a in d.Attachment) attachments.Add(a); foreach (var a in attachments) ctx.DeleteObject(a); //delete background if (d.Background != null) d.Background = null; foreach (var t in d.Topic) { t.Person.Clear(); t.ArgPoint.Clear(); } d.Topic.Clear(); d.GeneralSide.Clear(); ctx.DeleteObject(d); ctx.SaveChanges(); }
public ActionResult Edit([Bind(Include = "DiscussionId,Name,User")] Discussion discussion) { if (ModelState.IsValid) { db.Entry(discussion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(discussion)); }
public void SaveChanges() { Discussion discussion = DataContext as Discussion; if (discussion != null) { DaoUtils.EnsureBgExists(discussion); //discussion.Background.Text = txtBxBackground.Text; } }
public void updateDiscussionList(Discussion[] discussions) { disList = discussions; clearList(); for (int i = 0; i < disList.Length; i++) createNewLine(disList[i]); updateList(); }
public async Task AddAsync(Discussion discussion) { if (discussion == null) { throw new ArgumentException(); } await context.Discussions.AddAsync(discussion); await context.SaveChangesAsync(); }
public async Task <ActionResult <Discussion> > GetDiscussion(int discussionid) { Discussion discussion = await _forumLogic.GetDiscussion(discussionid); if (discussion == null) { return(StatusCode(404)); } StatusCode(200); return(discussion); }
// Start is called before the first frame update void Start() { //UI alignment //the width of scroll view. This is used to control the size of user entry. RectTransform rt = scrollView.GetComponent <RectTransform>(); scrollWidth = rt.rect.width; // set heading alignment RectTransform headingRT = heading.GetComponent <RectTransform>(); headingRT.sizeDelta = new Vector2(scrollWidth, headingRT.rect.height); headingRT.position = new Vector3(rt.position.x, headingRT.position.y, headingRT.position.z); for (int i = 0; i < heading.transform.childCount; i++) { GameObject child = heading.transform.GetChild(i).gameObject; RectTransform childRT = child.GetComponent <RectTransform>(); childRT.sizeDelta = new Vector2(scrollWidth / heading.transform.childCount, childRT.rect.height); } discussion = Discussion.getDiscussion(); Debug.Log("number of discussion: " + discussion.threads.Count); seeDetail = false; entries = new List <GameObject>(); postDetail = null; foreach (Thread post in discussion.threads) { GameObject go = (GameObject)Instantiate(userEntry); go.transform.SetParent(content.transform); go.transform.Find("Username").GetComponentInChildren <InputField>().text = post.username; go.transform.Find("Heading").GetComponentInChildren <InputField>().text = post.heading; go.transform.Find("nReplies").GetComponentInChildren <InputField>().text = post.noReplies.ToString(); go.transform.Find("Detail").GetComponent <Button>().onClick.AddListener(() => { postDetail = post; Debug.Log(postDetail.heading); seeDetail = true; }); //UI alignemnt for (int i = 0; i < go.transform.childCount; i++) { GameObject child = go.transform.GetChild(i).gameObject; RectTransform childRT = child.GetComponent <RectTransform>(); childRT.sizeDelta = new Vector2(scrollWidth / go.transform.childCount, childRT.rect.height); } go.transform.localScale = new Vector3(1f, 1f, 1f); entries.Add(go); } userEntry.SetActive(false); }
public ActionResult Create([Bind(Include = "DiscussionId,Name,User")] Discussion discussion) { if (ModelState.IsValid) { db.Discussions.Add(discussion); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(discussion)); }
public DeleteDiscussionCommandTest() { id = new Guid(); dbSetDiscussion = new Mock <DbSet <Discussion> >(); context = new Mock <IApplicationDbContext>(); stringLocalizer = new Mock <IStringLocalizer <DiscussionsResource> >(); discussion = new Discussion { Id = id }; }
//private methods private async Task NotifyMembers(Discussion discussion) { BookClub club = db.BookClubs.Find(discussion.ClubId); List <ClubMembers> clubMembers = db.ClubMembers.Include("Member").Where(cm => cm.ClubId == club.Id).ToList(); discussion.Book = db.BookDiscussions.Include("Book").FirstOrDefault(bd => bd.DiscussionId == discussion.Id).Book; foreach (ClubMembers cm in clubMembers) { await BookSiteEmailService.SendEmail(BuildEmailModel(cm.Member, discussion)); } }
/// <summary> /// Default constructor. /// </summary> public DiscussionInfoZoom(Discussion d) { InitializeComponent(); // Add handlers for window availability events AddWindowAvailabilityHandlers(); DataContext = d; bg.ToViewMode(); bg.SetCanReorderItems(false); }
/// <summary> /// Edits the discussion. /// </summary> /// <param name="discussion"></param> /// <returns></returns> public bool Edit(Discussion discussion) { if (!CheckDiscussionInput(discussion.Title, discussion.Content)) { return(false); } bool response = repo.Edit(discussion); return(response); }
/** * Add a discussion to the data set. * * @param discussion The discussion to be added. */ public void AddDiscussion(Discussion discussion) { if (discussion != null) { if (_discussions == null) { _discussions = new List <Discussion>(); } _discussions.Add(discussion); } }
public Discussion UpdateDiscussion(Discussion pDisc) { var newIds = GetUserIds(pDisc); UpdateInvitees(pDisc, newIds); pDisc.Tags = String.Join(",", pDisc.SelectedTags) + "," + pDisc.TagCsv; pDisc.DiscussionCrowd = pDisc.GetVisibilityCode(); _db.Entry(pDisc).State = System.Data.EntityState.Modified; _db.SaveChanges(); return(pDisc); }
public Discussion CreateOrUpdateDiscussion(Discussion pDisc) { if (pDisc.IsNew) { return(CreateDiscussion(pDisc)); } else { return(UpdateDiscussion(pDisc)); } }
internal FuseUser(SteamFriends handler) { this._Friends = new Dictionary <uint, User>(); this._OnlineFriends = new Dictionary <uint, User>(); this._OfflineFriends = new Dictionary <uint, User>(); this._Requesteds = new Dictionary <uint, User>(); this._Discussions = new Dictionary <uint, Discussion>(); this._CurrentDiscussion = null; this._FriendsHandler = handler; this._Localuser = null; }
public ActionResult Discussion(Parameter p) { if (p.Id == 0) { return(RedirectToAction("PageNotFoundError", "Home")); } LoginDetails loginDetails = (LoginDetails)Session["loginDetails"]; if (loginDetails == null) { return(RedirectToAction("PageNotFoundError", "Home")); } int user = (int)Session["user"]; if (user != 2) { return(RedirectToAction("PageNotFoundError", "Home")); } object o = Session["selectedClass"]; if (o == null) { return(RedirectToAction("PageNotFoundError", "Home")); } int id = (int)o; Course course = data.GetCourse(id); if (course == null) { return(RedirectToAction("PageNotFoundError", "Home")); } Discussion d = data.GetDiscussion(p.Id); if (d == null) { return(RedirectToAction("PageNotFoundError", "Home")); } int count = (from x in course.Discussions where x.Id == d.Id select x).Count(); if (count == 0) { return(RedirectToAction("PageNotFoundError", "Home")); } Session["discussionSelected"] = p.Id; Student s = data.GetStudent(loginDetails.Username); return(View(new StudentCourseViewModel { course = course, discussion = d, student = s })); }
public async Task <IHttpActionResult> GetDiscussion(int id) { Discussion discussion = await db.Discussions.FindAsync(id); if (discussion == null) { return(NotFound()); } return(Ok(discussion)); }
public void UpDisc(Discussion disc) { var originalDisc = _repo.Query <Discussion>().Where(d => d.Id == disc.Id).FirstOrDefault(); originalDisc.InterestName = disc.InterestName; originalDisc.ImageHeader = disc.ImageHeader; originalDisc.Headline = disc.Headline; originalDisc.Description = disc.Description; _repo.Update <Discussion>(originalDisc); //_repo.SaveChanges(); }
public async Task <IEnumerable <ChallengeChat> > GetChallengesGivenFromGroup(int discussionId) { Discussion discussion = await this.discussionRepository.GetDiscussionsWithGroup(discussionId); if (discussion.GroupId != null) { return(await this.challengeGivenRepository.GetChallengeChatByGroupId(discussion.GroupId.Value)); } return(new List <ChallengeChat>()); }
public Discussion GetLastestDiscussion(int tagid) { Discussion discussion = _dal.Repository <Discussion>().Include("Author").Table .Where(p => p.Tags.Where(t => t.Id == tagid).Count() > 0) .Distinct() .OrderByDescending(t => t.CreatedDate) .FirstOrDefault(); discussion.Author = _cService.GetUser(discussion.UserId); return(discussion); }
public async Task <IActionResult> Create([Bind("Name")] Discussion discussion) { if (ModelState.IsValid) { _context.Add(discussion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(discussion)); }
public ActionResult Edit([Bind(Include = "DicussionId,UserName,DiscussionPost,PackageId")] Discussion discussion) { if (ModelState.IsValid) { db.Entry(discussion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PackageId = new SelectList(db.Packages, "PackageId", "PackageName", discussion.PackageId); return(View(discussion)); }
public DiscussionDetailsVM(Discussion d) { discussion = d; posts = new PostBL().GetPosts(); posts.Where(x => x.DiscussionId == d.DiscussionId); posts.OrderBy(x => x.Posted); ForumContext db = new ForumContext(); var r = db.userDB.Where(b => b.username == name).ToList().First(); isAdmin = r.isAdmin; }
public async Task CreateDiscussionAsync(Guid userId, string slug, Discussion discussion, CancellationToken cancellationToken) { if (Guid.Empty == userId) { throw new ArgumentOutOfRangeException(nameof(userId)); } if (string.IsNullOrEmpty(slug)) { throw new ArgumentOutOfRangeException(nameof(slug)); } var now = _systemClock.UtcNow.UtcDateTime; var groupId = await _groupCommand.GetGroupIdForSlugAsync(slug, cancellationToken); if (!groupId.HasValue) { _logger.LogError($"Error: CreateDiscussionAsync - Group not found for slug:{0}", slug); throw new KeyNotFoundException("Error: Group not found for slug"); } var userCanPerformAction = await _permissionsService.UserCanPerformActionAsync(userId, groupId.Value, AddDiscussionRole, cancellationToken); if (!userCanPerformAction) { _logger.LogError($"Error: CreateDiscussionAsync - User:{0} does not have access to group:{1}", userId, slug); throw new SecurityException($"Error: User does not have access"); } var entityId = Guid.NewGuid(); var discussionDto = new DiscussionDto { Id = entityId, Title = discussion.Title, Content = discussion.Content, CreatedAtUTC = now, CreatedBy = userId, IsSticky = discussion.IsSticky, IsLocked = false, GroupId = groupId.Value }; var validator = new DiscussionValidator(); var validationResult = await validator.ValidateAsync(discussionDto, cancellationToken); if (validationResult.Errors.Count > 0) { throw new ValidationException(validationResult); } await _discussionCommand.CreateDiscussionAsync(discussionDto, cancellationToken); }
public static QDiscussion NormalView(Discussion p, User user) { return(p == null ? null : new QDiscussion { TopicId = p.TopicId, SenderId = p.SenderId, Text = p.Text, ImageUrl = p.Image, User = QUser.NormalView(user) }); }
public async Task UpdateAsync(int discussionId, Discussion newDiscussion) { var discussionToChange = await Get().FirstOrDefaultAsync(d => d.DiscussionId == discussionId); if (discussionToChange != null) { discussionToChange.DiscussionName = newDiscussion.DiscussionName; discussionToChange.Text = newDiscussion.Text; await context.SaveChangesAsync(); } }
public async Task <IActionResult> Create([Bind("DiscussionId,Comment,PostedAt,ContactInfoId")] Discussion discussion) { if (ModelState.IsValid) { _context.Add(discussion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContactInfoId"] = new SelectList(_context.ContactInfo, "ContactInfoId", "FirstName", discussion.ContactInfoId); return(View(discussion)); }
public ActionResult Edit([Bind(Include = "DiscussionID,CategoryID,Title,Body,PostDate,ReplyID,Email")] Discussion discussion) { if (ModelState.IsValid) { discussion.PostDate = DateTime.Now; db.Entry(discussion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", discussion.CategoryID); return(View(discussion)); }
public async Task <IHttpActionResult> PostDiscussion(Discussion discussion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Discussions.Add(discussion); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = discussion.DisscussionId }, discussion)); }
public ActionResult UpdateDiscussion(int id, Discussion discussion) { try { _discussionService.UpdateDiscussion(discussion); return(RedirectToAction("GetAllDiscussions", "Discussion", new { id = discussion.Id })); } catch { return(View()); } }
//Edit public async Task <ActionResult> Edit(int id) { Discussion discussion = await FindDiscussionAsync(id); if (discussion == null) { return(HttpNotFound()); } ViewBag.Items = GetAuthorsListItems(discussion.DiscussionId); return(View(discussion)); }
private bool SendNotificationEmail(int discussion, string name, Discussion.Message message, IEnumerable<string> people) { if (people.Any()) { var receivers = string.Join(";", people); string id = String.Format("{0}.{1}.{2}@teamworks.mailgun.org", discussion, message.Id, DateTime.Now.ToString("yyyymmddhhMMss")); try { message.Reply = MailHub.Send(MailgunConfiguration.Host, receivers, name, message.Content, id); } catch (Exception e) { return false; } } return (message.NotificationSent = true); }
public void Run(Session session, Topic topic, Discussion discussion, Person person) { //tests //var ctx = new DiscCtx(ConfigManager.ConnStr); //var discussion = ctx.Discussion.First(); //var topic = discussion.Topic.First(); //var session = ctx.Session.FirstOrDefault(); //var pers = session.Person.First(); //start hard report var reportParameters = new ReportParameters(session.Person.Select(p => p.Id).ToList(), session, topic, discussion); var tcs = new TaskCompletionSource<ReportCollector>(); new ReportCollector(null, ReportGenerated, reportParameters, tcs, UISharedRTClient.Instance.clienRt); var pdfAsm = new Reporter.pdf.PdfAssembler2(discussion, topic, person, session, Utils.RandomFilePath(".pdf"), tcs.Task, RemoteFinalSceneScreenshot(topic.Id, discussion.Id)); pdfAsm.RunAsync().GetAwaiter().OnCompleted(() => { }); }
public PdfAssembler2(Discussion discussion, Topic topic, Person person, Session session, string PdfPathName, Task<ReportCollector> hardReportTask, Task<Dictionary<int, byte[]>> finalScene) { _discussion = discussion; _topic = topic; _PdfPathName = PdfPathName; _person = person; _session = session; _hardReportTask = hardReportTask; _finalScene = finalScene; if (topic == null) { MessageDlg.Show("Null topic"); } if (discussion == null) { MessageDlg.Show("Null discussion"); } }
public static IEnumerable<Annotation> GetAnnotations(Discussion d) { var q = from ans in PublicBoardCtx.Get().Annotation where ans.Discussion.Id == d.Id select ans; return q; }
/// <summary> /// Retrieves all the comments in a discussion /// </summary> /// <param name="discussion">The discussion whose comments are to be retrieved</param> /// <param name="fields">The properties that should be set on the returned Comment. Type and Id are always set. If left null, all properties will be set, which can increase response time.</param> /// <returns>The discussion's comments</returns> public CommentCollection GetComments(Discussion discussion, IEnumerable<CommentField> fields = null) { GuardFromNull(discussion, "discussion"); return GetDiscussionComments(discussion.Id, fields); }
private void createNewLine(Discussion discussion) { int index = lines.Count; line tmp = new line(); hieght = minHeight; linesHeight.Add(hieght); tmp.comments = new List<TreeNode>(); tmp.tree = new TreeView(); tmp.dates = new List<string>(); tmp.publishers = new List<string>(); tmp.lblEdit = new Label(); tmp.lblDelete = new Label(); tmp.lnedComment = new TextBox(); tmp.btnComment = new Button(); tmp.lstDates = new ListBox(); tmp.lstPublishers = new ListBox(); initTreeView(tmp, index, discussion); initDeleteEditLbls(tmp ,index); initCommentLine(tmp, index); initDateList(tmp, index); initPublishersList(tmp, index); if (index % 2 == 0) { tmp.lblEdit.BackColor = System.Drawing.SystemColors.GradientActiveCaption; tmp.lblDelete.BackColor = System.Drawing.SystemColors.GradientActiveCaption; tmp.tree.BackColor = System.Drawing.SystemColors.GradientActiveCaption; tmp.lstDates.BackColor = System.Drawing.SystemColors.GradientActiveCaption; tmp.lstPublishers.BackColor = System.Drawing.SystemColors.GradientActiveCaption; } else { tmp.lblEdit.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; tmp.lblDelete.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; tmp.tree.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; tmp.lstDates.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; tmp.lstPublishers.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; } if (loginLevel != (int)loginLevels.GUEST) { this.pnlDiscussion.Controls.Add(tmp.lblDelete); this.pnlDiscussion.Controls.Add(tmp.lblEdit); } this.pnlDiscussion.Controls.Add(tmp.lstDates); this.pnlDiscussion.Controls.Add(tmp.lstPublishers); this.pnlDiscussion.Controls.Add(tmp.tree); lines.Add(tmp); nextY += tmp.tree.Size.Height; nextY += delta; }
public async Task<IHttpActionResult> PostMsg([FromBody] msg message, int id) { string msg = message.message; Utilisateur u = UserHelper.getUser(User, db); DateTime DateMsg = DateTime.Now; Discussion disc = new Discussion(); disc.DateMsg = DateMsg; disc.Message = msg; disc.OffreId = id; disc.UtilisateurId = u.Id; try { if (db.OffreSet.Find(id) != null) { db.DiscussionSet.Add(disc); await db.SaveChangesAsync(); return Created("Message bien envoyé", disc); } return NotFound(); } catch (Exception e) { return InternalServerError(e); } }
private void Run(Discussion A, Discussion B) { if (A == null || B == null) return; Tuple<int, int, string> range = GetRange(); if (range.Item3 != "") return; var ctx = PublicBoardCtx.Get(); var moderator = ctx.Person.FirstOrDefault(p => p.Name == "moderator"); if (moderator == null) { MessageDlg.Show("Cannot find moderator in DB"); return; } for (int i = range.Item1; i <= range.Item2; i++) { var disc = cloneDiscussion(ctx, A, moderator, i); DaoUtils.SetGeneralSide(moderator, disc, (int) SideCode.Neutral); ctx.AddToDiscussion(disc); var disc2 = cloneDiscussion(ctx, B, moderator, i); DaoUtils.SetGeneralSide(moderator, disc2, (int) SideCode.Neutral); ctx.AddToDiscussion(disc2); } ctx.SaveChanges(); MessageDlg.Show("Done"); }
/// <summary> /// Add a comment to a discussion /// </summary> /// <param name="onSuccess">The action to perform with the added comment</param> /// <param name="onFailure">Action to perform following a failed Comment operation</param> /// <param name="discussion">The discussion in which to comment</param> /// <param name="message">The message to add</param> /// <param name="fields">The properties that should be set on the returned Comment. Type and Id are always set. If left null, all properties will be set, which can increase response time.</param> public void CreateComment(Action<Comment> onSuccess, Action<Error> onFailure, Discussion discussion, string message, IEnumerable<CommentField> fields = null) { GuardFromNull(discussion, "discussion"); CreateDiscussionComment(onSuccess, onFailure, discussion.Id, message, fields); }
private void FillTopics(Discussion d) { topics.Clear(); foreach (var t in d.Topic) { topics.Add(t); } }
public DiscussionDashboard(UISharedRTClient sharedClient, StatusWnd stWnd, Discussions.Main.OnDiscFrmClosing closing) { this._discussion = SessionInfo.Get().discussion; _sharedClient = sharedClient; _closing = closing; _stWnd = stWnd; InitializeComponent(); userCursor = new UserCursor(SessionInfo.Get().person.Name, CursorInputState.None); userCursor.usrId = SessionInfo.Get().person.Id; SetListeners(sharedClient, true); if(sharedClient.clienRt.IsConnected()) OnJoin(); ToLayerModeNoLayer(); }
void ForgetDBDiscussionState() { //forget cached state CtxSingleton.DropContext(); _discussion = SessionInfo.Get().discussion; //_discussion = CtxSingleton.Get().Discussion.FirstOrDefault(d1 => d1.Id == _discussion.Id); if (selectedTopic != null) selectedTopic = _discussion.Topic.FirstOrDefault(t1 => t1.Id == selectedTopic.Id); ////////////////////// }
private static GeneralSide CreateGeneralSide(Person p, Discussion d, int side) { var genSide = new GeneralSide(); genSide.Side = (int) SideCode.Neutral; genSide.Discussion = d; genSide.Person = p; return genSide; }
//if given seat was not used in current session, and user takes the seat, new user is created in DB. //if user takes seat that was used in this session, then no new user is created. instead, the user //is recognized as the same user who took the seat in current session, though during second login user //enters name again (effectively changing name) private static Person RegisterOrLogin(string name, Discussion discussion, Session session, Seat seat) { //was the seat taken by some user? var sessionId = session.Id; var seatId = seat.Id; DbCtx.DropContext(); var outrunnerPerson = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Session != null && p0.Session.Id == sessionId && p0.Seat != null && p0.Seat.Id == seatId); //the user already took the place, just change name if (outrunnerPerson != null) { outrunnerPerson.Name = name; //do we need general side ? var ctx = DbCtx.Get(); var previousGenSide = ctx.GeneralSide.FirstOrDefault(gs0 => gs0.Discussion.Id == discussion.Id && gs0.Person.Id == outrunnerPerson.Id); if (previousGenSide == null) { //the person takes part in this discussion first time, create general //side of the person in this discussion var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id); outrunnerPerson.GeneralSide.Add( CreateGeneralSide( outrunnerPerson, disc, (int) SideCode.Neutral ) ); //assign person to all topics of selected discussion foreach (var topic in disc.Topic) outrunnerPerson.Topic.Add(topic); } DbCtx.Get().SaveChanges(); return outrunnerPerson; } else { //seat was not used in this session, create new user var ctx = DbCtx.Get(); var p = new Person(); p.Name = name; p.Session = ctx.Session.FirstOrDefault(s0 => s0.Id == session.Id); p.Seat = ctx.Seat.FirstOrDefault(s0 => s0.Id == seat.Id); var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id); p.GeneralSide.Add(CreateGeneralSide(p, disc, (int) SideCode.Neutral)); //person inherits color of seat p.Color = p.Seat.Color; p.Email = "no-email"; //assign person to all topics of selected discussion foreach (var topic in disc.Topic) p.Topic.Add(topic); ctx.AddToPerson(p); DbCtx.Get().SaveChanges(); return p; } }
/// <summary> /// Add a comment to a discussion /// </summary> /// <param name="discussion">The discussion in which to comment</param> /// <param name="message">The message to add</param> /// <param name="fields">The properties that should be set on the returned Comment. Type and Id are always set. If left null, all properties will be set, which can increase response time.</param> /// <returns>The discussion's new comment</returns> public Comment CreateComment(Discussion discussion, string message, IEnumerable<CommentField> fields = null) { GuardFromNull(discussion, "discussion"); return CreateDiscussionComment(discussion.Id, message, fields); }
/// <summary> /// Retrieves an existing discussion /// </summary> /// <param name="discussion">The discussion to retrieve</param> /// <param name="fields">The properties that should be set on the returned Discussion. Type and Id are always set. If left null, all properties will be set, which can increase response time.</param> /// <returns>The retrieved discussion</returns> public Discussion GetDiscussion(Discussion discussion, IEnumerable<DiscussionField> fields = null) { GuardFromNull(discussion, "discussion"); var request = _requestHelper.Get(ResourceType.Discussion, discussion.Id, fields); return _restClient.ExecuteAndDeserialize<Discussion>(request); }
public Discussion cloneDiscussion(DiscCtx ctx, Discussion original, Person moderator, int i) { var d = new Discussion(); d.Subject = injectNumber(original.Subject, i); //copy background d.Background = new RichText(); d.Background.Text = original.Background.Text; foreach (var src in original.Background.Source) { var s = new Source(); s.Text = src.Text; s.OrderNumber = src.OrderNumber; d.Background.Source.Add(s); } foreach (var media in original.Attachment) { var attach = new Attachment(); attach.Discussion = d; attach.Format = media.Format; attach.Link = media.Link; attach.Name = media.Name; attach.Title = media.Title; attach.VideoEmbedURL = media.VideoEmbedURL; attach.VideoLinkURL = media.VideoLinkURL; attach.VideoThumbURL = media.VideoThumbURL; attach.OrderNumber = media.OrderNumber; if (media.Thumb != null) attach.Thumb = (byte[]) media.Thumb.Clone(); if (media.MediaData != null && media.MediaData.Data != null) { var mediaClone = new MediaData(); mediaClone.Data = (byte[]) media.MediaData.Data.Clone(); attach.MediaData = mediaClone; } attach.Person = moderator; d.Attachment.Add(attach); } d.HtmlBackground = original.HtmlBackground; foreach (var topic in original.Topic) { var t = new Topic(); t.Name = injectNumber(topic.Name, i); t.Person.Add(moderator); d.Topic.Add(t); } return d; }
/// <summary> /// Retrieves an existing discussion /// </summary> /// <param name="onSuccess">Action to perform with the retrieved discussion</param> /// <param name="onFailure">Action to perform following a failed retrieval</param> /// <param name="discussion">The discussion to retrieve</param> /// <param name="fields">The properties that should be set on the returned Discussion. Type and Id are always set. If left null, all properties will be set, which can increase response time.</param> public void GetDiscussion(Action<Discussion> onSuccess, Action<Error> onFailure, Discussion discussion, IEnumerable<DiscussionField> fields = null) { GuardFromNull(discussion, "discussion"); GuardFromNullCallbacks(onSuccess, onFailure); var request = _requestHelper.Get(ResourceType.Discussion, discussion.Id, fields); _restClient.ExecuteAsync(request, onSuccess, onFailure); }
/// <summary> /// Retrieves all the comments in a discussion /// </summary> /// <param name="onSuccess">Action to perform with the discussion's comments</param> /// <param name="onFailure">Action to perform following a failed Comment operation</param> /// <param name="discussion">The discussion whose comments are to be retrieved</param> /// <param name="fields">The properties that should be set on the returned CommentCollection. Type and Id are always set. If left null, all properties will be set, which can increase response time.</param> public void GetComments(Action<CommentCollection> onSuccess, Action<Error> onFailure, Discussion discussion, IEnumerable<CommentField> fields = null) { GuardFromNull(discussion, "discussion"); GetDiscussionComments(onSuccess, onFailure, discussion.Id, fields); }
/// <summary> /// Deletes a discussion from a folder /// </summary> /// <param name="discussion">The discussion to delete</param> public void Delete(Discussion discussion) { GuardFromNull(discussion, "discussion"); DeleteDiscussion(discussion.Id); }
private void initTreeView(line tmp, int index, Discussion discussion) { // // treeView + nodes // Comment[] comm = mainMethods.getCommentList(discussion.discussionId); tmp.publishers.Add(discussion.publisher.userName); tmp.dates.Add(discussion.publishDate.ToString()); tmp.dates.Add(""); tmp.publishers.Add(""); for (int i = 0; i < comm.Length; i++) { TreeNode treeNodeTmp = new TreeNode(comm[i].content); tmp.comments.Add(treeNodeTmp); tmp.publishers.Add(comm[i].publisher.userName); tmp.dates.Add(comm[i].publishDate.ToString()); } tmp.tnodeContent = new TreeNode("Msg Content", tmp.comments.ToArray<TreeNode>()); tmp.tnodeTitle = new TreeNode("Hello Forum!", new System.Windows.Forms.TreeNode[] { tmp.tnodeContent }); tmp.tree.BorderStyle = System.Windows.Forms.BorderStyle.None; tmp.tree.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); tmp.tree.ForeColor = System.Drawing.SystemColors.InfoText; tmp.tree.FullRowSelect = true; tmp.tree.Indent = 13; tmp.tree.ItemHeight = 20; tmp.tree.LineColor = System.Drawing.Color.White; tmp.tree.Location = new System.Drawing.Point(0, nextY); tmp.tree.Name = index.ToString(); // tmp.tnodeContent.Name = "content"; tmp.tnodeContent.Text = discussion.content; // tmp.tnodeTitle.Name = "title"; tmp.tnodeTitle.NodeFont = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); tmp.tnodeTitle.Text = discussion.title; // tmp.tree.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { tmp.tnodeTitle }); tmp.tree.Size = new System.Drawing.Size(780, hieght); //need to calculate according to the number of comments + add comment line tmp.tree.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(treeViewBeforeCollapse); tmp.tree.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(treeViewBeforeExpand); }
/// <summary> /// Deletes a discussion from a folder /// </summary> /// <param name="onSuccess">Action to perform following a successful delete</param> /// <param name="onFailure">Action to perform following a failed delete</param> /// <param name="discussion">The discussion to delete</param> public void Delete(Action<IRestResponse> onSuccess, Action<Error> onFailure, Discussion discussion) { GuardFromNull(discussion, "discussion"); DeleteDiscussion(onSuccess, onFailure, discussion.Id); }
public static IEnumerable<ArgPoint> ArgPointsOf(Person pers, Discussion d, Topic t) { return pers.ArgPoint.Where(ap => ap.Topic != null && ap.Topic.Id == t.Id); }
private void lstBxDiscussions_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectedDiscussion = e.AddedItems[0] as Discussion; Close(); }