public ActionResult AssignContact(ViewModels.Matters.MatterContactViewModel model) { Common.Models.Account.Users currentUser; Common.Models.Matters.MatterContact matterContact; // We need to reset the Id of the model as it is picking up the id from the route, // which is incorrect model.Id = null; currentUser = Data.Account.Users.Get(User.Identity.Name); matterContact = Data.Matters.MatterContact.Get(model.Matter.Id.Value, model.Contact.Id.Value); if (matterContact == null) { // Create matterContact = Mapper.Map <Common.Models.Matters.MatterContact>(model); matterContact = Data.Matters.MatterContact.Create(matterContact, currentUser); } else { // Enable matterContact = Mapper.Map <Common.Models.Matters.MatterContact>(model); matterContact = Data.Matters.MatterContact.Enable(matterContact, currentUser); } if (model.Role == "Lead Attorney") { Common.Models.Matters.Matter matter = Data.Matters.Matter.Get(model.Matter.Id.Value); matter.LeadAttorney = Mapper.Map <Common.Models.Contacts.Contact>(model.Contact); Data.Matters.Matter.Edit(matter, currentUser); } return(RedirectToAction("Contacts", "Matters", new { id = matterContact.Matter.Id.Value.ToString() })); }
public ActionResult Edit(Guid id, ViewModels.Billing.ExpenseViewModel viewModel) { Common.Models.Account.Users currentUser; Common.Models.Matters.Matter matter = null; Common.Models.Billing.Expense model; using (Data.Transaction trans = Data.Transaction.Create(true)) { try { currentUser = Data.Account.Users.Get(trans, User.Identity.Name); matter = Data.Billing.Expense.GetMatter(trans, id); model = Mapper.Map <Common.Models.Billing.Expense>(viewModel); model = Data.Billing.Expense.Edit(trans, model, currentUser); trans.Commit(); return(RedirectToAction("Details", "Matters", new { Id = matter.Id })); } catch { trans.Rollback(); return(Edit(id)); } } }
public static List <Common.Models.Notes.NoteTask> ListAllTaskNotes( Common.Models.Matters.Matter model, IDbConnection conn = null, bool closeConnection = true) { List <Common.Models.Notes.NoteTask> list = new List <Common.Models.Notes.NoteTask>(); IEnumerable <DBOs.Notes.NoteTask> ie = null; conn = DataHelper.OpenIfNeeded(conn); ie = conn.Query <DBOs.Notes.NoteTask>( "SELECT * FROM \"note_task\" JOIN \"note\" ON \"note_task\".\"note_id\"=\"note\".\"id\" " + "WHERE \"note_task\".\"utc_disabled\" is null AND \"task_id\" IN (SELECT \"task_id\" FROM \"task_matter\" WHERE \"matter_id\"=@MatterId) " + "ORDER BY note.timestamp DESC", new { MatterId = model.Id }); DataHelper.Close(conn, closeConnection); foreach (DBOs.Notes.NoteTask dbo in ie) { list.Add(Mapper.Map <Common.Models.Notes.NoteTask>(dbo)); } return(list); }
public static Common.Models.Matters.Matter Create( Common.Models.Matters.Matter model, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { // Matter if (!model.Id.HasValue) { model.Id = Guid.NewGuid(); } model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Matters.Matter dbo = Mapper.Map <DBOs.Matters.Matter>(model); conn = DataHelper.OpenIfNeeded(conn); conn.Execute("INSERT INTO \"matter\" (\"id\", \"matter_type_id\", \"title\", \"active\", \"parent_id\", \"synopsis\", " + "\"minimum_charge\", \"estimated_charge\", \"maximum_charge\", \"default_billing_rate_id\", \"billing_group_id\", \"override_matter_rate_with_employee_rate\", " + "\"attorney_for_party_title\", \"court_type_id\", \"court_geographical_jurisdiction_id\", \"court_sitting_in_city_id\", \"caption_plaintiff_or_subject_short\", " + "\"caption_plaintiff_or_subject_regular\", \"caption_plaintiff_or_subject_long\", \"caption_other_party_short\", " + "\"caption_other_party_regular\", \"caption_other_party_long\", " + "\"utc_created\", \"utc_modified\", " + "\"created_by_user_pid\", \"modified_by_user_pid\", \"case_number\", \"bill_to_contact_id\") " + "VALUES (@Id, @MatterTypeId, @Title, @Active, @ParentId, @Synopsis, @MinimumCharge, @EstimatedCharge, @MaximumCharge, @DefaultBillingRateId, @BillingGroupId, @OverrideMatterRateWithEmployeeRate, " + "@AttorneyForPartyTitle, @CourtTypeId, @CourtGeographicalJurisdictionId, @CourtSittingInCityId, @CaptionPlaintiffOrSubjectShort, " + "@CaptionPlaintiffOrSubjectRegular, @CaptionPlaintiffOrSubjectLong, @CaptionOtherPartyShort, @CaptionOtherPartyRegular, @CaptionOtherPartyLong, " + "@UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId, " + "@CaseNumber, @BillToContactId)", dbo); return(model); }
private void MatterContactAssignment( ViewModels.Matters.MatterContactViewModel viewModel, Common.Models.Matters.Matter matter, Common.Models.Account.Users currentUser, Data.Transaction trans) { if (viewModel != null && viewModel.Contact != null && viewModel.Contact.Id.HasValue) { Common.Models.Matters.MatterContact mcOld; mcOld = Data.Matters.MatterContact.Get(matter.Id.Value, viewModel.Contact.Id.Value); if (mcOld == null) { // Create Common.Models.Matters.MatterContact mcNew; mcNew = Mapper.Map <Common.Models.Matters.MatterContact>(viewModel); mcNew.Matter = matter; mcNew = Data.Matters.MatterContact.Create(trans, mcNew, currentUser); } else { // Enable Common.Models.Matters.MatterContact mcNew; mcNew = Mapper.Map <Common.Models.Matters.MatterContact>(viewModel); mcNew.Matter = matter; mcNew.Id = mcOld.Id; mcNew = Data.Matters.MatterContact.Enable(trans, mcNew, currentUser); mcNew = Data.Matters.MatterContact.Edit(trans, mcNew, currentUser); } } }
public static Common.Models.Matters.Matter Edit( Common.Models.Matters.Matter model, Common.Models.Account.Users modifier, IDbConnection conn = null, bool closeConnection = true) { model.ModifiedBy = modifier; model.Modified = DateTime.UtcNow; DBOs.Matters.Matter dbo = Mapper.Map <DBOs.Matters.Matter>(model); conn = DataHelper.OpenIfNeeded(conn); conn.Execute("UPDATE \"matter\" SET \"matter_type_id\"=@MatterTypeId, " + "\"title\"=@Title, \"active\"=@Active, \"parent_id\"=@ParentId, \"synopsis\"=@Synopsis, \"utc_modified\"=@UtcModified, " + "\"minimum_charge\"=@MinimumCharge, \"estimated_charge\"=@EstimatedCharge, \"maximum_charge\"=@MaximumCharge, " + "\"default_billing_rate_id\"=@DefaultBillingRateId, \"billing_group_id\"=@BillingGroupId, \"override_matter_rate_with_employee_rate\"=@OverrideMatterRateWithEmployeeRate, " + "\"attorney_for_party_title\"=@AttorneyForPartyTitle, \"court_type_id\"=@CourtTypeId, \"court_geographical_jurisdiction_id\"=@CourtGeographicalJurisdictionId, " + "\"court_sitting_in_city_id\"=@CourtSittingInCityId, \"caption_plaintiff_or_subject_short\"=@CaptionPlaintiffOrSubjectShort, " + "\"caption_plaintiff_or_subject_regular\"=@CaptionPlaintiffOrSubjectRegular, \"caption_plaintiff_or_subject_long\"=@CaptionPlaintiffOrSubjectLong, " + "\"caption_other_party_short\"=@CaptionOtherPartyShort, " + "\"caption_other_party_regular\"=@CaptionOtherPartyRegular, \"caption_other_party_long\"=@CaptionOtherPartyLong, " + "\"modified_by_user_pid\"=@ModifiedByUserPId, \"case_number\"=@CaseNumber, \"bill_to_contact_id\"=@BillToContactId " + "WHERE \"id\"=@Id", dbo); return(model); }
public static Common.Models.Matters.Matter Create( Transaction t, Common.Models.Matters.Matter model, Common.Models.Account.Users creator) { return(Create(model, creator, t.Connection, false)); }
public static List <Common.Models.Notes.NoteTask> ListAllNotes(Common.Models.Matters.Matter model) { List <Common.Models.Notes.NoteTask> list = new List <Common.Models.Notes.NoteTask>(); IEnumerable <DBOs.Notes.NoteTask> ie = null; using (IDbConnection conn = Database.Instance.GetConnection()) { ie = conn.Query <DBOs.Notes.NoteTask>( "SELECT \"note_id\", \"task_id\", \"note\".\"id\" AS \"note_id\", \"note_task\".\"id\" AS \"id\" " + //\"note_task\".\"id\", \"note_task\".\"created_by_user_pid\", \"note_task\".\"modified_by_user_pid\", \"note_task\".\"disabled_by_user_pid\", " + //"\"note_task\".\"utc_created\", \"note_task\".\"utc_modified\", \"note_task\".\"utc_disabled\", \"note\".\"id\", \"note_task\".\"id\" "FROM \"note_task\" " + "FULL OUTER JOIN \"note\" ON \"note\".\"id\"=\"note_task\".\"note_id\" " + "WHERE \"task_id\" IN (SELECT \"task_id\" FROM \"task_matter\" WHERE \"matter_id\"=@MatterId) OR " + "\"note\".\"id\" IN (SELECT \"note_id\" FROM \"note_matter\" WHERE \"matter_id\"=@MatterId) " + "ORDER BY \"note\".\"timestamp\" DESC", new { MatterId = model.Id }); } foreach (DBOs.Notes.NoteTask dbo in ie) { list.Add(Mapper.Map <Common.Models.Notes.NoteTask>(dbo)); } return(list); }
public static Common.Models.Matters.Matter Edit( Transaction t, Common.Models.Matters.Matter model, Common.Models.Account.Users modifier) { return(Edit(model, modifier, t.Connection, false)); }
public ActionResult CloseWithNewTask(long id) { Common.Models.Account.Users currentUser; Common.Models.Tasks.Task model; using (Data.Transaction trans = Data.Transaction.Create(true)) { try { currentUser = Data.Account.Users.Get(trans, User.Identity.Name); model = Data.Tasks.Task.Get(trans, id); model.Active = false; model.ActualEnd = DateTime.Now; model = Data.Tasks.Task.Edit(trans, model, currentUser); Common.Models.Matters.Matter matter = Data.Tasks.Task.GetRelatedMatter(trans, id); trans.Commit(); return(RedirectToAction("Create", "Tasks", new { MatterId = matter.Id })); } catch { trans.Rollback(); return(Close(id)); } } }
ListMatterRelationshipsForContact(int contactId, Guid matterId) { List <Tuple <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact> > dbo = null; List <Tuple <Common.Models.Matters.Matter, Common.Models.Matters.MatterContact, Common.Models.Contacts.Contact> > modelList = new List <Tuple <Common.Models.Matters.Matter, Common.Models.Matters.MatterContact, Common.Models.Contacts.Contact> >(); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Open(); dbo = conn.Query <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact, Tuple <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact> > ("SELECT * FROM \"matter\" " + "JOIN \"matter_contact\" ON \"matter\".\"id\"=\"matter_contact\".\"matter_id\" " + "JOIN \"contact\" ON \"matter_contact\".\"contact_id\"=\"contact\".\"id\" " + "WHERE \"matter\".\"id\"=@MatterId " + "AND \"contact\".\"id\"!=@ContactId", (mtr, matterContact, contact) => { return(new Tuple <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact>(mtr, matterContact, contact)); }, new { MatterId = matterId, ContactId = contactId }).ToList(); } dbo.ForEach(x => { Common.Models.Matters.Matter m = Mapper.Map <Common.Models.Matters.Matter>(x.Item1); Common.Models.Matters.MatterContact mc = Mapper.Map <Common.Models.Matters.MatterContact>(x.Item2); Common.Models.Contacts.Contact c = Mapper.Map <Common.Models.Contacts.Contact>(x.Item3); modelList.Add(new Tuple <Common.Models.Matters.Matter, Common.Models.Matters.MatterContact, Common.Models.Contacts.Contact>(m, mc, c)); }); return(modelList); }
public ActionResult Close(long id, ViewModels.Tasks.TaskViewModel viewModel) { Common.Models.Account.Users currentUser; Common.Models.Tasks.Task model; using (Data.Transaction trans = Data.Transaction.Create(true)) { try { currentUser = Data.Account.Users.Get(trans, User.Identity.Name); model = Data.Tasks.Task.Get(trans, id); model.Active = false; model.ActualEnd = DateTime.Now; model = Data.Tasks.Task.Edit(trans, model, currentUser); if (!string.IsNullOrEmpty(Request["NewTask"]) && Request["NewTask"] == "on") { // not empty & "on" Common.Models.Matters.Matter matter = Data.Tasks.Task.GetRelatedMatter(trans, id); return(RedirectToAction("Create", "Tasks", new { MatterId = matter.Id })); } trans.Commit(); return(RedirectToAction("Details", new { Id = id })); } catch { trans.Rollback(); return(Close(id)); } } }
public ActionResult Create() { List <ViewModels.Contacts.ContactViewModel> employeeContactList; Common.Models.Matters.Matter matter = null; Common.Models.Tasks.Task task = null; employeeContactList = new List <ViewModels.Contacts.ContactViewModel>(); if (Request["MatterId"] != null) { matter = Data.Matters.Matter.Get(Guid.Parse(Request["MatterId"])); } else if (Request["TaskId"] != null) { task = Data.Tasks.Task.Get(long.Parse(Request["TaskId"])); matter = Data.Tasks.Task.GetRelatedMatter(task.Id.Value); ViewData["TaskId"] = task.Id.Value; ViewData["Task"] = task.Title; } Data.Contacts.Contact.ListEmployeesOnly().ForEach(x => { employeeContactList.Add(Mapper.Map <ViewModels.Contacts.ContactViewModel>(x)); }); ViewData["MatterId"] = matter.Id.Value; ViewData["Matter"] = matter.Title; ViewData["EmployeeContactList"] = employeeContactList; return(View(new ViewModels.Notes.NoteViewModel() { Timestamp = DateTime.Now })); }
public static List <Common.Models.Notes.NoteTask> ListAllNotes( Common.Models.Matters.Matter model, IDbConnection conn = null, bool closeConnection = true) { List <Common.Models.Notes.NoteTask> list = new List <Common.Models.Notes.NoteTask>(); IEnumerable <DBOs.Notes.NoteTask> ie = null; conn = DataHelper.OpenIfNeeded(conn); ie = conn.Query <DBOs.Notes.NoteTask>( "SELECT \"note_id\", \"task_id\", \"note\".\"id\" AS \"note_id\", \"note_task\".\"id\" AS \"id\" " + //\"note_task\".\"id\", \"note_task\".\"created_by_user_pid\", \"note_task\".\"modified_by_user_pid\", \"note_task\".\"disabled_by_user_pid\", " + //"\"note_task\".\"utc_created\", \"note_task\".\"utc_modified\", \"note_task\".\"utc_disabled\", \"note\".\"id\", \"note_task\".\"id\" "FROM \"note_task\" " + "FULL OUTER JOIN \"note\" ON \"note\".\"id\"=\"note_task\".\"note_id\" " + "WHERE \"task_id\" IN (SELECT \"task_id\" FROM \"task_matter\" WHERE \"matter_id\"=@MatterId) OR " + "\"note\".\"id\" IN (SELECT \"note_id\" FROM \"note_matter\" WHERE \"matter_id\"=@MatterId) " + "ORDER BY \"note\".\"timestamp\" DESC", new { MatterId = model.Id }); DataHelper.Close(conn, closeConnection); foreach (DBOs.Notes.NoteTask dbo in ie) { list.Add(Mapper.Map <Common.Models.Notes.NoteTask>(dbo)); } return(list); }
public static Common.Models.Events.EventMatter RelateToMatter(Common.Models.Events.Event model, Common.Models.Matters.Matter matter, Common.Models.Account.Users actor) { Common.Models.Events.EventMatter em; DBOs.Events.EventMatter dbo = null; em = Data.Events.EventMatter.Get(model.Id.Value, matter.Id.Value); if (em != null) { return(em); } em = new Common.Models.Events.EventMatter(); em.Id = Guid.NewGuid(); em.CreatedBy = em.ModifiedBy = actor; em.Created = em.Modified = DateTime.UtcNow; em.Event = model; em.Matter = matter; dbo = Mapper.Map <DBOs.Events.EventMatter>(em); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("INSERT INTO \"event_matter\" (\"id\", \"event_id\", \"matter_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Id, @EventId, @MatterId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo); } return(em); }
public static List <Common.Models.Matters.Matter> ListPossibleDuplicates(Common.Models.Matters.Matter model) { DBOs.Matters.Matter dbo = Mapper.Map <DBOs.Matters.Matter>(model); return(DataHelper.List <Common.Models.Matters.Matter, DBOs.Matters.Matter>( "SELECT * FROM \"matter\" WHERE (LOWER(\"title\") LIKE '%' || LOWER(@Title) || '%') OR " + //"OR (LOWER(\"title\") LIKE '%' || @Title || '%') OR " + "(\"jurisdiction\"=@Jurisdiction AND " + "\"case_number\"=@CaseNumber) OR (\"bill_to_contact_id\"=@BillToContactId AND \"case_number\"=@CaseNumber) AND \"utc_disabled\" is null", dbo)); }
public ActionResult Edit(Guid id, ViewModels.Assets.AssetViewModel viewModel) { Common.Models.Account.Users currentUser; // FS layout // Asset/Version/File Common.Models.Assets.Asset asset; asset = Mapper.Map <Common.Models.Assets.Asset>(viewModel); using (Data.Transaction trans = Data.Transaction.Create()) { try { currentUser = Data.Account.Users.Get(User.Identity.Name); Common.Models.Matters.Matter matter = Data.Matters.Matter.Get(trans, id); Data.Assets.Asset.Edit(trans, asset, currentUser); viewModel.Tags = new List <ViewModels.Assets.TagViewModel>(); Request.Params["Tags"].Split(',').ToList().ForEach(x => { viewModel.Tags.Add(new ViewModels.Assets.TagViewModel() { Name = x.Trim() }); }); // Disassociate all asset_asset_tags for this asset Data.Assets.AssetTag.DeleteAllForAsset(trans, asset.Id.Value); foreach (ViewModels.Assets.TagViewModel tag in viewModel.Tags) { if (tag != null) { Common.Models.Assets.Tag mTag = Mapper.Map <Common.Models.Assets.Tag>(tag); Data.Assets.Tag.Create(trans, mTag, currentUser); Data.Assets.AssetTag.Create(trans, new Common.Models.Assets.AssetTag() { Asset = asset, Tag = mTag }, currentUser); } } trans.Commit(); } catch (Exception ex) { trans.Rollback(); } } return(RedirectToAction("Details", new { Id = asset.Id })); }
public static List <Common.Models.Matters.Matter> ListPossibleDuplicates( Common.Models.Matters.Matter model, IDbConnection conn = null, bool closeConnection = true) { DBOs.Matters.Matter dbo = Mapper.Map <DBOs.Matters.Matter>(model); return(DataHelper.List <Common.Models.Matters.Matter, DBOs.Matters.Matter>( "SELECT * FROM \"matter\" WHERE (LOWER(\"title\") LIKE '%' || LOWER(@Title) || '%') OR " + //"OR (LOWER(\"title\") LIKE '%' || @Title || '%') OR " + "(\"court_type_id\"=@CourtTypeId AND \"court_geographical_jurisdiction_id\"=@CourtGeographicalJurisdictionId AND " + "\"case_number\"=@CaseNumber) OR (\"bill_to_contact_id\"=@BillToContactId AND \"case_number\"=@CaseNumber) AND \"utc_disabled\" is null", dbo, conn, closeConnection)); }
public ActionResult Create() { Common.Models.Matters.Matter matter = null; matter = Data.Matters.Matter.Get(Guid.Parse(Request["MatterId"])); ViewData["MatterId"] = matter.Id.Value; ViewData["Matter"] = matter.Title; return(View(new ViewModels.Billing.FeeViewModel() { Incurred = DateTime.Now })); }
public ActionResult Create() { Common.Models.Matters.Matter matter = null; using (IDbConnection conn = Data.Database.Instance.GetConnection()) { matter = Data.Matters.Matter.Get(Guid.Parse(Request["MatterId"])); } ViewBag.Matter = Mapper.Map <ViewModels.Matters.MatterViewModel>(matter); return(View(new ViewModels.Billing.FeeViewModel() { Incurred = DateTime.Now })); }
public static Common.Models.Matters.Matter Edit(Common.Models.Matters.Matter model, Common.Models.Account.Users modifier) { model.ModifiedBy = modifier; model.Modified = DateTime.UtcNow; List <Common.Models.Matters.MatterContact> leadAttorneyMatches; DBOs.Matters.Matter dbo = Mapper.Map <DBOs.Matters.Matter>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("UPDATE \"matter\" SET \"matter_type_id\"=@MatterTypeId, " + "\"title\"=@Title, \"active\"=@Active, \"parent_id\"=@ParentId, \"synopsis\"=@Synopsis, \"utc_modified\"=@UtcModified, " + "\"minimum_charge\"=@MinimumCharge, \"estimated_charge\"=@EstimatedCharge, \"maximum_charge\"=@MaximumCharge, " + "\"default_billing_rate_id\"=@DefaultBillingRateId, \"billing_group_id\"=@BillingGroupId, \"override_matter_rate_with_employee_rate\"=@OverrideMatterRateWithEmployeeRate, " + "\"modified_by_user_pid\"=@ModifiedByUserPId, \"jurisdiction\"=@Jurisdiction, \"case_number\"=@CaseNumber, \"lead_attorney_contact_id\"=@LeadAttorneyContactId, \"bill_to_contact_id\"=@BillToContactId " + "WHERE \"id\"=@Id", dbo); } leadAttorneyMatches = MatterContact.ListForMatterByRole(dbo.Id, "Lead Attorney"); if (leadAttorneyMatches.Count > 1) { throw new Exception("More than one Lead Attorney found."); } else if (leadAttorneyMatches.Count < 1) { // Insert only MatterContact.Create(new Common.Models.Matters.MatterContact() { Matter = model, Contact = new Common.Models.Contacts.Contact() { Id = dbo.LeadAttorneyContactId.Value }, Role = "Lead Attorney" }, modifier); } else { // Replace leadAttorneyMatches[0].Contact.Id = dbo.LeadAttorneyContactId.Value; MatterContact.Edit(leadAttorneyMatches[0], modifier); } return(model); }
void ThisAddIn_ActiveMatterChanged(object oldValue, object newValue) { if (newValue == null) { group1.Visible = false; ActiveMatterTitle.Label = ""; FormSelector.Items.Clear(); } else { Common.Models.Matters.Matter matter = (Common.Models.Matters.Matter)newValue; Task task; group1.Visible = true; ActiveMatterTitle.Label = matter.Title; task = new Task(() => { Common.Net.Response <List <Common.Models.Forms.Form> > resp; resp = CommManager.ListFormsForMatter(matter.Id.Value); if (Extensions.DynamicPropertyExists(resp.Package, "Error")) { if (Globals.ThisAddIn.CanLog) { LogManager.GetCurrentClassLogger().Error("Error: " + resp.Error); } } else { resp.Package.ForEach(x => { RibbonDropDownItem item = Factory.CreateRibbonDropDownItem(); item.Label = x.Title; item.Tag = x; FormSelector.Items.Add(item); }); } }); task.Start(); } }
public ActionResult Delete(int id, ViewModels.Matters.MatterContactViewModel viewModel) { Common.Models.Account.Users currentUser; Common.Models.Matters.MatterContact model; currentUser = Data.Account.Users.Get(User.Identity.Name); model = Mapper.Map <Common.Models.Matters.MatterContact>(viewModel); model = Data.Matters.MatterContact.Disable(model, currentUser); if (model.Role == "Lead Attorney") { Common.Models.Matters.Matter matter = Data.Matters.Matter.Get(model.Matter.Id.Value); matter.LeadAttorney = null; Data.Matters.Matter.Edit(matter, currentUser); } return(RedirectToAction("Contacts", "Matters", new { id = model.Matter.Id.Value.ToString() })); }
public ActionResult Close(long id, ViewModels.Tasks.TaskViewModel viewModel) { Common.Models.Account.Users currentUser; Common.Models.Tasks.Task model; currentUser = Data.Account.Users.Get(User.Identity.Name); model = Data.Tasks.Task.Get(id); model.Active = false; model.ActualEnd = DateTime.Now; model = Data.Tasks.Task.Edit(model, currentUser); if (!string.IsNullOrEmpty(Request["NewTask"]) && Request["NewTask"] == "on") { // not empty & "on" Common.Models.Matters.Matter matter = Data.Tasks.Task.GetRelatedMatter(id); return(RedirectToAction("Create", "Tasks", new { MatterId = matter.Id })); } return(RedirectToAction("Details", new { Id = id })); }
public static List <Common.Models.Notes.NoteTask> ListAllTaskNotes(Common.Models.Matters.Matter model) { List <Common.Models.Notes.NoteTask> list = new List <Common.Models.Notes.NoteTask>(); IEnumerable <DBOs.Notes.NoteTask> ie = null; using (IDbConnection conn = Database.Instance.GetConnection()) { ie = conn.Query <DBOs.Notes.NoteTask>( "SELECT * FROM \"note_task\" JOIN \"note\" ON \"note_task\".\"note_id\"=\"note\".\"id\" " + "WHERE \"note_task\".\"utc_disabled\" is null AND \"task_id\" IN (SELECT \"task_id\" FROM \"task_matter\" WHERE \"matter_id\"=@MatterId) " + "ORDER BY note.timestamp DESC", new { MatterId = model.Id }); } foreach (DBOs.Notes.NoteTask dbo in ie) { list.Add(Mapper.Map <Common.Models.Notes.NoteTask>(dbo)); } return(list); }
private void MatterResults_SelectedIndexChanged(object sender, EventArgs e) { Common.Models.Matters.Matter matter = (Common.Models.Matters.Matter)MatterResults.SelectedItem; Task task; ProgressBarForm.Show(); Globals.ThisAddIn.ActiveMatter = matter; task = new Task(() => { Common.Net.Response <List <Common.Models.Forms.Form> > resp; resp = CommManager.ListFormsForMatter(matter.Id.Value); if (Extensions.DynamicPropertyExists(resp.Package, "Error")) { if (Globals.ThisAddIn.CanLog) { LogManager.GetCurrentClassLogger().Error("Error: " + resp.Error); } MessageBox.Show("Error: " + resp.Error, "Error"); } else { FormResults.Invoke(new MethodInvoker(delegate { FormResults.DataSource = resp.Package; FormResults.DisplayMember = "Title"; FormResults.ValueMember = "Id"; ProgressBarForm.Hide(); FormResults.Enabled = true; Select.Enabled = true; })); } }); task.Start(); }
ListMatterRelationshipsForContact( int contactId, Guid matterId, IDbConnection conn = null, bool closeConnection = true) { List <Tuple <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact> > dbo = null; List <Tuple <Common.Models.Matters.Matter, Common.Models.Matters.MatterContact, Common.Models.Contacts.Contact> > modelList = new List <Tuple <Common.Models.Matters.Matter, Common.Models.Matters.MatterContact, Common.Models.Contacts.Contact> >(); conn = DataHelper.OpenIfNeeded(conn); dbo = conn.Query <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact, Tuple <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact> > ("SELECT * FROM \"matter\" " + "JOIN \"matter_contact\" ON \"matter\".\"id\"=\"matter_contact\".\"matter_id\" " + "JOIN \"contact\" ON \"matter_contact\".\"contact_id\"=\"contact\".\"id\" " + "WHERE \"matter\".\"id\"=@MatterId " + "AND \"contact\".\"id\"!=@ContactId", (mtr, matterContact, contact) => { return(new Tuple <DBOs.Matters.Matter, DBOs.Matters.MatterContact, DBOs.Contacts.Contact>(mtr, matterContact, contact)); }, new { MatterId = matterId, ContactId = contactId }).ToList(); DataHelper.Close(conn, closeConnection); dbo.ForEach(x => { Common.Models.Matters.Matter m = Mapper.Map <Common.Models.Matters.Matter>(x.Item1); Common.Models.Matters.MatterContact mc = Mapper.Map <Common.Models.Matters.MatterContact>(x.Item2); Common.Models.Contacts.Contact c = Mapper.Map <Common.Models.Contacts.Contact>(x.Item3); modelList.Add(new Tuple <Common.Models.Matters.Matter, Common.Models.Matters.MatterContact, Common.Models.Contacts.Contact>(m, mc, c)); }); return(modelList); }
public static Common.Models.Events.EventMatter RelateToMatter(Common.Models.Events.Event model, Common.Models.Matters.Matter matter, Common.Models.Account.Users actor, IDbConnection conn = null, bool closeConnection = true) { Common.Models.Events.EventMatter em; DBOs.Events.EventMatter dbo = null; em = Data.Events.EventMatter.Get(model.Id.Value, matter.Id.Value); if (em != null) { return(em); } em = new Common.Models.Events.EventMatter(); em.Id = Guid.NewGuid(); em.CreatedBy = em.ModifiedBy = actor; em.Created = em.Modified = DateTime.UtcNow; em.Event = model; em.Matter = matter; dbo = Mapper.Map <DBOs.Events.EventMatter>(em); conn = DataHelper.OpenIfNeeded(conn); if (conn.Execute("INSERT INTO \"event_matter\" (\"id\", \"event_id\", \"matter_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Id, @EventId, @MatterId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo) > 0) { model.Id = conn.Query <DBOs.Events.EventMatter>("SELECT currval(pg_get_serial_sequence('event_matter', 'id')) AS \"id\"").Single().Id; } DataHelper.Close(conn, closeConnection); return(em); }
public static Common.Models.Matters.Matter Create(Common.Models.Matters.Matter model, Common.Models.Account.Users creator) { // Matter if (!model.Id.HasValue) { model.Id = Guid.NewGuid(); } model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Matters.Matter dbo = Mapper.Map <DBOs.Matters.Matter>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("INSERT INTO \"matter\" (\"id\", \"matter_type_id\", \"title\", \"active\", \"parent_id\", \"synopsis\", " + "\"minimum_charge\", \"estimated_charge\", \"maximum_charge\", \"default_billing_rate_id\", \"billing_group_id\", \"override_matter_rate_with_employee_rate\", " + "\"utc_created\", \"utc_modified\", " + "\"created_by_user_pid\", \"modified_by_user_pid\", \"jurisdiction\", \"case_number\", \"lead_attorney_contact_id\", \"bill_to_contact_id\") " + "VALUES (@Id, @MatterTypeId, @Title, @Active, @ParentId, @Synopsis, @MinimumCharge, @EstimatedCharge, @MaximumCharge, @DefaultBillingRateId, @BillingGroupId, @OverrideMatterRateWithEmployeeRate, " + "@UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId, " + "@Jurisdiction, @CaseNumber, @LeadAttorneyContactId, @BillToContactId)", dbo); } MatterContact.Create(new Common.Models.Matters.MatterContact() { Matter = model, Contact = new Common.Models.Contacts.Contact() { Id = dbo.LeadAttorneyContactId.Value }, Role = "Lead Attorney" }, creator); return(model); }
public ActionResult Create() { List <ViewModels.Contacts.ContactViewModel> employeeContactList; Common.Models.Matters.Matter matter = null; Common.Models.Tasks.Task task = null; employeeContactList = new List <ViewModels.Contacts.ContactViewModel>(); using (IDbConnection conn = Data.Database.Instance.GetConnection()) { if (Request["MatterId"] != null) { matter = Data.Matters.Matter.Get(Guid.Parse(Request["MatterId"]), conn, false); } else if (Request["TaskId"] != null) { task = Data.Tasks.Task.Get(long.Parse(Request["TaskId"]), conn, false); matter = Data.Tasks.Task.GetRelatedMatter(task.Id.Value, conn, false); ViewBag.Task = task; } Data.Contacts.Contact.ListEmployeesOnly(conn, false).ForEach(x => { employeeContactList.Add(Mapper.Map <ViewModels.Contacts.ContactViewModel>(x)); }); } ViewBag.Matter = matter; ViewBag.EmployeeContactList = employeeContactList; return(View(new ViewModels.Notes.NoteViewModel() { Timestamp = DateTime.Now })); }