Пример #1
0
        public async t.Task RemoveToDoCommentAsync(string id, ToDoComment comment)
        {
            string cmd = String.Format(@"DELETE FROM ToDoComments WHERE ID = '{0}' AND Time = '{1}';",
                                       id, comment.Time);

            await ExecuteQueryAsync(cmd);
        }
Пример #2
0
        ///<summary>
        /// typeparameter T must be <c>ToDoComment</c>
        ///</summary>
        public async t.Task UpdateToDoCommandAsync(string id, ToDoComment comment)
        {
            string cmd = String.Format("UPDATE ToDoComments SET Content = '{0}' WHERE ID = '{1}' AND Time = '{2}';",
                                       comment.Content, id, comment.Time);

            await ExecuteQueryAsync(cmd);
        }
Пример #3
0
        //
        //
        //------ Cooming soon -------begin--------------------------
        #region ToDoComment Query Method
        public async t.Task InsertToDoCommentAsync(ToDoComment comment)
        {
            string cmd = String.Format(@"INSERT INTO ToDoComments(Time, Content) VALUES ('{0}', '{1}');",
                                       comment.Time, comment.Content);

            await ExecuteQueryAsync(cmd);
        }
Пример #4
0
        internal void RemoveToDoComment(string id, ToDoComment comment)
        {
            string cmd = String.Format(@"DELETE FROM ToDoComments WHERE ID = '{0}' AND Time = DATE('{1}');",
                                       id, comment.Time);

            ExecuteQuery(cmd).ContinueWith(t => { if (t.IsFaulted)
                                                  {
                                                      throw t.Exception;
                                                  }
                                           });
        }
Пример #5
0
        ///<summary>
        /// typeparameter T must be <c>ToDoComment</c>
        ///</summary>
        internal void UpdateToDoCommand(string id, ToDoComment comment)
        {
            string cmd = String.Format("UPDATE ToDoComments SET Content = '{0}' WHERE ID = '{1}' AND Time = DATE('{2}');",
                                       comment.Content, id, comment.Time);

            ExecuteQuery(cmd).ContinueWith(t => { if (t.IsFaulted)
                                                  {
                                                      throw t.Exception;
                                                  }
                                           });
        }
Пример #6
0
        internal void InsertToDoComment(ToDoComment comment)
        {
            string cmd = String.Format(@"INSERT INTO ToDoComments(Time, Content) VALUES (DATE('{0}'), '{1}');",
                                       comment.Time, comment.Content);

            ExecuteQuery(cmd).ContinueWith(t => { if (t.IsFaulted)
                                                  {
                                                      throw t.Exception;
                                                  }
                                           });
        }
Пример #7
0
        public async System.Threading.Tasks.Task <ActionResult> Detail(int id, ToDo model, FormCollection formcol)
        {
            if (formcol["Save"] == "Save")
            {
                var cx = new ToDoDBContext();
                if (id == 0)
                {
                    model.GId     = Guid.NewGuid();
                    model.Created = DateTime.Now;
                    cx.ToDoes.Add(model);
                    cx.SaveChanges();

                    //Send to sservice bus
                    ServiceBusHelper.SendToAll(model);
                }
                else
                {
                    var p = cx.ToDoes.Single(e => e.Id == id);
                    p.Note     = model.Note;
                    p.Category = model.Category;
                    cx.SaveChanges();
                }
            }
            else if (formcol["Comment"] == "Comment")
            {
                if (formcol["CommentText"].Length > 0)
                {
                    var td = new ToDoComment();
                    td.Id      = Guid.NewGuid();
                    td.ToDoGId = model.GId;
                    td.Created = DateTime.Now;
                    td.Comment = formcol["CommentText"];
                    var doc = new DocDBContext();
                    await doc.InsertComment(td);

                    return(RedirectToAction("Detail", new { id = id }));
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #8
0
        public CommentModel AddComment(string projectId, string milestoneId, string toDoId, string text, bool isPrivate, bool sendNotifications, List <UrlViewModel> attachments)
        {
            var project = GetProject(projectId);
            var todo    = GetToDo(project, milestoneId, toDoId);
            var comment = new ToDoComment()
            {
                Date         = DateTime.Now,
                Text         = text,
                UserFullName = CurrentUser.FullName,
                UserObjectId = CurrentUser.Id,
                IsPrivate    = isPrivate
            };

            attachments.BindUrls(comment.Attachments);

            todo.Comments.Add(comment);
            UpdateProject(project);

            var idea = GetIdea(project.IdeaId);

            bus.Send(new ProjectCommand()
            {
                ActionType        = ActionTypes.ToDoCommentAdded,
                ProjectId         = project.Id,
                MileStoneId       = milestoneId,
                UserId            = CurrentUser.Id,
                ToDoId            = todo.Id,
                Text              = comment.Text,
                ProjectSubject    = idea.Subject,
                Link              = GetProjectUrl(project.Id),
                ToDoSubject       = todo.Subject,
                ToDoLink          = Url.ActionAbsolute("Comments", "Project", new { projectId = project.Id, toDoId = todo.Id }),
                IsPrivate         = idea.IsPrivateToOrganization && !string.IsNullOrEmpty(idea.OrganizationId) || todo.IsPrivate || comment.IsPrivate,
                CommentId         = comment.Id,
                SendNotifications = sendNotifications,
                UserFullName      = CurrentUser.FullName,
                UserLink          = Url.ActionAbsolute("Details", "Account", new { userObjectId = CurrentUser.Id })
            });

            return(GetCommentModelFromComment(comment, project, milestoneId, toDoId, false));
        }
Пример #9
0
 public CommentModel GetCommentModelFromComment(ToDoComment c, Project project, string milestoneId, string toDoId, bool isIdeaClosed)
 {
     return(new CommentModel()
     {
         AuthorFullName = c.UserFullName,
         AuthorObjectId = c.UserObjectId,
         CommentDate = c.Date,
         CommentText = c.Text.NewLineToHtml().ActivateLinks(),
         ProjectId = project.Id,
         Id = c.Id,
         MileStoneId = milestoneId,
         ToDoId = toDoId,
         IsDeletable =
             CurrentUser.IsAuthenticated && c.UserObjectId == CurrentUser.Id &&
             IsProjectEditable(project, isIdeaClosed),
         Attachments = c.Attachments.Select(a => new UrlViewModel()
         {
             IconUrl = a.IconUrl,
             Url = a.Url,
             Title = a.Title
         }).ToList()
     });
 }
 public async Task InsertComment(ToDoComment itm)
 {
     await client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, databaseCollectionName), itm);
 }