Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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));
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }