public static Common.Models.Notes.Note Create( Transaction t, Common.Models.Notes.Note model, Common.Models.Account.Users creator) { return(Create(model, creator, t.Connection, false)); }
public static Common.Models.Notes.Note Edit( Transaction t, Common.Models.Notes.Note model, Common.Models.Account.Users modifier) { return(Edit(model, modifier, t.Connection, false)); }
public static Common.Models.Notes.NoteTask RelateTask( Transaction t, Common.Models.Notes.Note model, long taskId, Common.Models.Account.Users creator) { return(RelateTask(model, taskId, creator, t.Connection, false)); }
public static Common.Models.Notes.NoteMatter RelateMatter( Transaction t, Common.Models.Notes.Note model, Guid matterId, Common.Models.Account.Users creator) { return(RelateMatter(model, matterId, creator, t.Connection, false)); }
public static Common.Models.Events.EventNote RelateEvent( Transaction t, Common.Models.Notes.Note model, Guid eventId, Common.Models.Account.Users creator) { return(RelateEvent(model, eventId, creator, t.Connection, false)); }
public static Common.Models.Notes.NoteTask RelateTask(Common.Models.Notes.Note model, long taskId, Common.Models.Account.Users creator) { return(NoteTask.Create(new Common.Models.Notes.NoteTask() { Id = Guid.NewGuid(), Note = model, Task = new Common.Models.Tasks.Task { Id = taskId }, CreatedBy = creator, ModifiedBy = creator, Created = DateTime.UtcNow, Modified = DateTime.UtcNow }, creator)); }
public static Common.Models.Notes.Note Edit(Common.Models.Notes.Note model, Common.Models.Account.Users modifier) { model.ModifiedBy = modifier; model.Modified = DateTime.UtcNow; DBOs.Notes.Note dbo = Mapper.Map <DBOs.Notes.Note>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("UPDATE \"note\" SET " + "\"title\"=@Title, \"body\"=@Body, \"timestamp\"=@Timestamp, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " + "WHERE \"id\"=@Id", dbo); } return(model); }
public static Common.Models.Events.EventNote RelateEvent(Common.Models.Notes.Note model, Guid eventId, Common.Models.Account.Users creator) { return(Events.EventNote.Create(new Common.Models.Events.EventNote() { Id = Guid.NewGuid(), Note = model, Event = new Common.Models.Events.Event() { Id = eventId }, CreatedBy = creator, ModifiedBy = creator, Created = DateTime.UtcNow, Modified = DateTime.UtcNow }, creator)); }
public static Common.Models.Notes.NoteMatter RelateMatter(Common.Models.Notes.Note model, Guid matterId, Common.Models.Account.Users creator) { return(NoteMatter.Create(new Common.Models.Notes.NoteMatter() { Id = Guid.NewGuid(), Note = model, Matter = new Common.Models.Matters.Matter() { Id = matterId }, CreatedBy = creator, ModifiedBy = creator, Created = DateTime.UtcNow, Modified = DateTime.UtcNow }, creator)); }
public static Common.Models.Notes.Note Create(Common.Models.Notes.Note model, Common.Models.Account.Users creator) { if (!model.Id.HasValue) { model.Id = Guid.NewGuid(); } model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Notes.Note dbo = Mapper.Map <DBOs.Notes.Note>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("INSERT INTO \"note\" (\"id\", \"title\", \"body\", \"timestamp\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Id, @Title, @Body, @Timestamp, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo); } return(model); }
public static Common.Models.Notes.NoteTask RelateTask( Common.Models.Notes.Note model, long taskId, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { return(NoteTask.Create(new Common.Models.Notes.NoteTask() { Id = Guid.NewGuid(), Note = model, Task = new Common.Models.Tasks.Task { Id = taskId }, CreatedBy = creator, ModifiedBy = creator, Created = DateTime.UtcNow, Modified = DateTime.UtcNow }, creator, conn, closeConnection)); }
public static Common.Models.Notes.Note Edit( Common.Models.Notes.Note model, Common.Models.Account.Users modifier, IDbConnection conn = null, bool closeConnection = true) { model.ModifiedBy = modifier; model.Modified = DateTime.UtcNow; DBOs.Notes.Note dbo = Mapper.Map <DBOs.Notes.Note>(model); conn = DataHelper.OpenIfNeeded(conn); conn.Execute("UPDATE \"note\" SET " + "\"title\"=@Title, \"body\"=@Body, \"timestamp\"=@Timestamp, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " + "WHERE \"id\"=@Id", dbo); DataHelper.Close(conn, closeConnection); return(model); }
public static Common.Models.Events.EventNote RelateEvent( Common.Models.Notes.Note model, Guid eventId, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { return(Events.EventNote.Create(new Common.Models.Events.EventNote() { Id = Guid.NewGuid(), Note = model, Event = new Common.Models.Events.Event() { Id = eventId }, CreatedBy = creator, ModifiedBy = creator, Created = DateTime.UtcNow, Modified = DateTime.UtcNow }, creator, conn, closeConnection)); }
public static Common.Models.Notes.NoteMatter RelateMatter( Common.Models.Notes.Note model, Guid matterId, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { return(NoteMatter.Create(new Common.Models.Notes.NoteMatter() { Id = Guid.NewGuid(), Note = model, Matter = new Common.Models.Matters.Matter() { Id = matterId }, CreatedBy = creator, ModifiedBy = creator, Created = DateTime.UtcNow, Modified = DateTime.UtcNow }, creator, conn, closeConnection)); }
public static Common.Models.Notes.Note Create( Common.Models.Notes.Note model, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { if (!model.Id.HasValue) { model.Id = Guid.NewGuid(); } model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Notes.Note dbo = Mapper.Map <DBOs.Notes.Note>(model); conn = DataHelper.OpenIfNeeded(conn); conn.Execute("INSERT INTO \"note\" (\"id\", \"title\", \"body\", \"timestamp\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Id, @Title, @Body, @Timestamp, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo); DataHelper.Close(conn, closeConnection); return(model); }
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)); } } }
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); } } }