public static Common.Models.Events.EventMatter Create(Common.Models.Events.EventMatter model,
                                                              Common.Models.Account.Users creator,
                                                              IDbConnection conn = null, bool closeConnection = true)
        {
            DBOs.Events.EventMatter          dbo;
            Common.Models.Events.EventMatter currentModel;

            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.Created   = model.Modified = DateTime.UtcNow;
            model.CreatedBy = model.ModifiedBy = creator;

            currentModel = Get(model.Event.Id.Value, model.Matter.Id.Value);

            if (currentModel != null)
            {
                return(currentModel);
            }

            dbo = Mapper.Map <DBOs.Events.EventMatter>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            throw new Exception("this is broke");
            conn.Execute("UPDATE \"event_assigned_conttter\" (\"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);
            DataHelper.Close(conn, closeConnection);

            return(model);
        }
示例#2
0
        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);
        }
示例#3
0
        public static Common.Models.Events.EventMatter Create(Common.Models.Events.EventMatter model,
                                                              Common.Models.Account.Users creator)
        {
            DBOs.Events.EventMatter          dbo;
            Common.Models.Events.EventMatter currentModel;

            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.Created   = model.Modified = DateTime.UtcNow;
            model.CreatedBy = model.ModifiedBy = creator;

            currentModel = Get(model.Event.Id.Value, model.Matter.Id.Value);

            if (currentModel != null)
            {
                return(currentModel);
            }

            dbo = Mapper.Map <DBOs.Events.EventMatter>(model);

            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(model);
        }
示例#4
0
 public static void Delete(Common.Models.Events.EventMatter model, Common.Models.Account.Users deleter)
 {
     using (IDbConnection conn = Database.Instance.GetConnection())
     {
         conn.Execute("DELETE FROM \"event_matter\" WHERE \"id\"=@Id",
                      new { Id = model.Id.Value });
     }
 }
        public static void Delete(Common.Models.Events.EventMatter model, Common.Models.Account.Users deleter,
                                  IDbConnection conn = null, bool closeConnection = true)
        {
            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("DELETE FROM \"event_matter\" WHERE \"id\"=@Id",
                         new { Id = model.Id.Value });

            DataHelper.Close(conn, closeConnection);
        }
示例#6
0
        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);
        }
示例#7
0
        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;
        }
示例#8
0
        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;
        }