コード例 #1
0
 public static Common.Models.Tasks.TaskAssignedContact Enable(
     Transaction t,
     Common.Models.Tasks.TaskAssignedContact model,
     Common.Models.Account.Users enabler)
 {
     return(Enable(model, enabler, t.Connection, false));
 }
コード例 #2
0
        public static Common.Models.Tasks.TaskAssignedContact Create(
            Common.Models.Tasks.TaskAssignedContact model,
            Common.Models.Account.Users creator,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.Created   = model.Modified = DateTime.UtcNow;
            model.CreatedBy = model.ModifiedBy = creator;

            DBOs.Tasks.TaskAssignedContact dbo = Mapper.Map <DBOs.Tasks.TaskAssignedContact>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("INSERT INTO \"task_assigned_contact\" (\"id\", \"task_id\", \"contact_id\", \"assignment_type\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                         "VALUES (@Id, @TaskId, @ContactId, @AssignmentType, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                         dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
コード例 #3
0
 public static Common.Models.Tasks.TaskAssignedContact Edit(
     Transaction t,
     Common.Models.Tasks.TaskAssignedContact model,
     Common.Models.Account.Users modifier)
 {
     return(Edit(model, modifier, t.Connection, false));
 }
コード例 #4
0
 public static Common.Models.Tasks.TaskAssignedContact Create(
     Transaction t,
     Common.Models.Tasks.TaskAssignedContact model,
     Common.Models.Account.Users creator)
 {
     return(Create(model, creator, t.Connection, false));
 }
コード例 #5
0
        public static Common.Models.Tasks.TaskAssignedContact Disable(Common.Models.Tasks.TaskAssignedContact model,
                                                                      Common.Models.Account.Users disabler)
        {
            model.DisabledBy = disabler;
            model.Disabled   = DateTime.UtcNow;

            DataHelper.Disable <Common.Models.Tasks.TaskAssignedContact,
                                DBOs.Tasks.TaskAssignedContact>("task_assigned_contact", disabler.PId.Value, model.Id);

            return(model);
        }
コード例 #6
0
        public static Common.Models.Tasks.TaskAssignedContact Disable(
            Common.Models.Tasks.TaskAssignedContact model,
            Common.Models.Account.Users disabler,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.DisabledBy = disabler;
            model.Disabled   = DateTime.UtcNow;

            DataHelper.Disable <Common.Models.Tasks.TaskAssignedContact,
                                DBOs.Tasks.TaskAssignedContact>("task_assigned_contact", disabler.PId.Value,
                                                                model.Id, conn, closeConnection);

            return(model);
        }
コード例 #7
0
        public static Common.Models.Tasks.TaskAssignedContact Edit(Common.Models.Tasks.TaskAssignedContact model,
                                                                   Common.Models.Account.Users modifier)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Tasks.TaskAssignedContact dbo = Mapper.Map <DBOs.Tasks.TaskAssignedContact>(model);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("UPDATE \"task_assigned_contact\" SET " +
                             "\"task_id\"=@TaskId, \"contact_id\"=@ContactId, \"assignment_type\"=@AssignmentType, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                             "WHERE \"id\"=@Id", dbo);
            }

            return(model);
        }
コード例 #8
0
        public static Common.Models.Tasks.TaskAssignedContact Edit(
            Common.Models.Tasks.TaskAssignedContact model,
            Common.Models.Account.Users modifier,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Tasks.TaskAssignedContact dbo = Mapper.Map <DBOs.Tasks.TaskAssignedContact>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("UPDATE \"task_assigned_contact\" SET " +
                         "\"task_id\"=@TaskId, \"contact_id\"=@ContactId, \"assignment_type\"=@AssignmentType, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                         "WHERE \"id\"=@Id", dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
コード例 #9
0
        public static Common.Models.Tasks.TaskAssignedContact Create(Common.Models.Tasks.TaskAssignedContact model,
                                                                     Common.Models.Account.Users creator)
        {
            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.Created   = model.Modified = DateTime.UtcNow;
            model.CreatedBy = model.ModifiedBy = creator;

            DBOs.Tasks.TaskAssignedContact dbo = Mapper.Map <DBOs.Tasks.TaskAssignedContact>(model);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("INSERT INTO \"task_assigned_contact\" (\"id\", \"task_id\", \"contact_id\", \"assignment_type\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Id, @TaskId, @ContactId, @AssignmentType, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo);
            }

            return(model);
        }
コード例 #10
0
        public ActionResult PhoneCall(Guid id, ViewModels.Tasks.PhoneCallViewModel viewModel)
        {
            int contactId;

            Common.Models.Account.Users  currentUser;
            Common.Models.Matters.Matter matter;

            dynamic profile = ProfileBase.Create(Membership.GetUser().UserName);

            if (profile.ContactId == null && string.IsNullOrEmpty(profile.ContactId))
            {
                throw new Exception("Profile.ContactId not configured.");
            }

            using (Data.Transaction trans = Data.Transaction.Create(true))
            {
                try
                {
                    contactId   = int.Parse(profile.ContactId);
                    currentUser = Data.Account.Users.Get(trans, User.Identity.Name);
                    matter      = Data.Matters.Matter.Get(trans, id);

                    // Task
                    Common.Models.Tasks.Task task = new Common.Models.Tasks.Task()
                    {
                        Active      = true,
                        DueDate     = DateTime.Now,
                        Title       = viewModel.Title,
                        Description = new Ganss.XSS.HtmlSanitizer().Sanitize(viewModel.TaskAndNoteDetails)
                    };

                    // TaskAssignedContact
                    Common.Models.Tasks.TaskAssignedContact taskAssignedContact = new Common.Models.Tasks.TaskAssignedContact()
                    {
                        Contact = new Common.Models.Contacts.Contact()
                        {
                            Id = contactId
                        },
                        Task           = task,
                        AssignmentType = Common.Models.Tasks.AssignmentType.Direct
                    };

                    // Time
                    Common.Models.Timing.Time time = new Common.Models.Timing.Time()
                    {
                        Billable     = viewModel.Billable,
                        Details      = viewModel.TimeDetails,
                        Start        = viewModel.Start,
                        Stop         = viewModel.Stop,
                        TimeCategory = new Common.Models.Timing.TimeCategory()
                        {
                            Id = viewModel.TimeCategory.Id.Value
                        },
                        Worker = new Common.Models.Contacts.Contact()
                        {
                            Id = contactId
                        }
                    };

                    // Note
                    Common.Models.Notes.Note note = new Common.Models.Notes.Note()
                    {
                        Body      = viewModel.TaskAndNoteDetails,
                        Timestamp = DateTime.Now,
                        Title     = viewModel.Title
                    };


                    task = Data.Tasks.Task.Create(trans, task, currentUser);
                    Data.Tasks.Task.RelateMatter(trans, task, matter.Id.Value, currentUser);
                    Data.Tasks.TaskAssignedContact.Create(trans, taskAssignedContact, currentUser);

                    if (viewModel.MakeTime)
                    {
                        time = Data.Timing.Time.Create(trans, time, currentUser);
                        Data.Timing.Time.RelateTask(trans, time, task.Id.Value, currentUser);
                    }

                    if (viewModel.MakeNote)
                    {
                        note = Data.Notes.Note.Create(trans, note, currentUser);
                        Data.Notes.Note.RelateTask(trans, note, task.Id.Value, currentUser);

                        if (viewModel.NotifyContactIds != null)
                        {
                            foreach (string x in viewModel.NotifyContactIds)
                            {
                                Data.Notes.NoteNotification.Create(trans, new Common.Models.Notes.NoteNotification()
                                {
                                    Contact = new Common.Models.Contacts.Contact()
                                    {
                                        Id = int.Parse(x)
                                    },
                                    Note    = note,
                                    Cleared = null
                                }, currentUser);
                            }
                            ;
                        }
                    }

                    trans.Commit();

                    return(RedirectToAction("Details", "Tasks", new { Id = task.Id }));
                }
                catch
                {
                    trans.Rollback();
                    return(PhoneCall(id));
                }
            }
        }
コード例 #11
0
        public ActionResult PhoneCall(Guid id, ViewModels.Tasks.PhoneCallViewModel viewModel)
        {
            int contactId;
            Common.Models.Account.Users currentUser;
            Common.Models.Matters.Matter matter;

            dynamic profile = ProfileBase.Create(Membership.GetUser().UserName);
            if (profile.ContactId == null && string.IsNullOrEmpty(profile.ContactId))
                throw new Exception("Profile.ContactId not configured.");

            using (Data.Transaction trans = Data.Transaction.Create(true))
            {
                try
                {
                    contactId = int.Parse(profile.ContactId);
                    currentUser = Data.Account.Users.Get(trans, User.Identity.Name);
                    matter = Data.Matters.Matter.Get(trans, id);

                    // Task
                    Common.Models.Tasks.Task task = new Common.Models.Tasks.Task()
                    {
                        Active = true,
                        DueDate = DateTime.Now,
                        Title = viewModel.Title,
                        Description = new Ganss.XSS.HtmlSanitizer().Sanitize(viewModel.TaskAndNoteDetails)
                    };

                    // TaskAssignedContact
                    Common.Models.Tasks.TaskAssignedContact taskAssignedContact = new Common.Models.Tasks.TaskAssignedContact()
                    {
                        Contact = new Common.Models.Contacts.Contact() { Id = contactId },
                        Task = task,
                        AssignmentType = Common.Models.Tasks.AssignmentType.Direct
                    };

                    // Time
                    Common.Models.Timing.Time time = new Common.Models.Timing.Time()
                    {
                        Billable = viewModel.Billable,
                        Details = viewModel.TimeDetails,
                        Start = viewModel.Start,
                        Stop = viewModel.Stop,
                        Worker = new Common.Models.Contacts.Contact() { Id = contactId }
                    };

                    // Note
                    Common.Models.Notes.Note note = new Common.Models.Notes.Note()
                    {
                        Body = viewModel.TaskAndNoteDetails,
                        Timestamp = DateTime.Now,
                        Title = viewModel.Title
                    };


                    task = Data.Tasks.Task.Create(trans, task, currentUser);
                    Data.Tasks.Task.RelateMatter(trans, task, matter.Id.Value, currentUser);
                    Data.Tasks.TaskAssignedContact.Create(trans, taskAssignedContact, currentUser);

                    if (viewModel.MakeTime)
                    {
                        time = Data.Timing.Time.Create(trans, time, currentUser);
                        Data.Timing.Time.RelateTask(trans, time, task.Id.Value, currentUser);
                    }

                    if (viewModel.MakeNote)
                    {
                        note = Data.Notes.Note.Create(trans, note, currentUser);
                        Data.Notes.Note.RelateTask(trans, note, task.Id.Value, currentUser);

                        if (viewModel.NotifyContactIds != null)
                        {
                            foreach (string x in viewModel.NotifyContactIds)
                            {
                                Data.Notes.NoteNotification.Create(trans, new Common.Models.Notes.NoteNotification()
                                {
                                    Contact = new Common.Models.Contacts.Contact() { Id = int.Parse(x) },
                                    Note = note,
                                    Cleared = null
                                }, currentUser);
                            };
                        }
                    }

                    trans.Commit();

                    return RedirectToAction("Details", "Tasks", new { Id = task.Id });
                }
                catch
                {
                    trans.Rollback();
                    return PhoneCall(id);
                }
            }
        }