Beispiel #1
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);
        }
Beispiel #2
0
        public static Common.Models.Events.EventTask RelateToTask(Common.Models.Events.Event model,
                                                                  Common.Models.Tasks.Task task,
                                                                  Common.Models.Account.Users actor)
        {
            Common.Models.Events.EventTask et;
            DBOs.Events.EventTask          dbo = null;

            et = Data.Events.EventTask.Get(task.Id.Value, model.Id.Value);

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

            et           = new Common.Models.Events.EventTask();
            et.Id        = Guid.NewGuid();
            et.CreatedBy = et.ModifiedBy = actor;
            et.Created   = et.Modified = DateTime.UtcNow;
            et.Event     = model;
            et.Task      = task;

            dbo = Mapper.Map <DBOs.Events.EventTask>(et);

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

            return(et);
        }
Beispiel #3
0
 public static Common.Models.Events.EventTask RelateToTask(Common.Models.Events.Event model,
                                                           long taskId,
                                                           Common.Models.Account.Users actor)
 {
     return(RelateToTask(model, new Common.Models.Tasks.Task()
     {
         Id = taskId
     }, actor));
 }
Beispiel #4
0
 public static Common.Models.Events.EventMatter RelateToMatter(Common.Models.Events.Event model,
                                                               Guid matterId,
                                                               Common.Models.Account.Users actor)
 {
     return(RelateToMatter(model, new Common.Models.Matters.Matter()
     {
         Id = matterId
     }, actor));
 }
        public ActionResult Create(Guid id)
        {
            Common.Models.Events.Event model = Data.Events.Event.Get(id);

            return(View(new ViewModels.Events.EventTagViewModel()
            {
                Event = Mapper.Map <ViewModels.Events.EventViewModel>(model)
            }));
        }
 public static Common.Models.Events.EventTask RelateToTask(Common.Models.Events.Event model,
                                                           long taskId,
                                                           Common.Models.Account.Users actor,
                                                           IDbConnection conn = null, bool closeConnection = true)
 {
     return(RelateToTask(model, new Common.Models.Tasks.Task()
     {
         Id = taskId
     }, actor, conn, closeConnection));
 }
 public static Common.Models.Events.EventMatter RelateToMatter(Common.Models.Events.Event model,
                                                               Guid matterId,
                                                               Common.Models.Account.Users actor,
                                                               IDbConnection conn = null, bool closeConnection = true)
 {
     return(RelateToMatter(model, new Common.Models.Matters.Matter()
     {
         Id = matterId
     }, actor, conn, closeConnection));
 }
Beispiel #8
0
        public static Common.Models.Events.Event Edit(Common.Models.Events.Event model,
                                                      Common.Models.Account.Users modifier)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Events.Event dbo = Mapper.Map <DBOs.Events.Event>(model);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("UPDATE \"event\" SET " +
                             "\"title\"=@Title, \"allday\"=@AllDay, \"start\"=@Start, " +
                             "\"end\"=@End, \"location\"=@Location, \"description\"=@Description, " +
                             "\"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                             "WHERE \"id\"=@Id", dbo);
            }

            return(model);
        }
        public static Common.Models.Events.Event Edit(Common.Models.Events.Event model,
                                                      Common.Models.Account.Users modifier,
                                                      IDbConnection conn = null, bool closeConnection = true)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Events.Event dbo = Mapper.Map <DBOs.Events.Event>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("UPDATE \"event\" SET " +
                         "\"title\"=@Title, \"allday\"=@AllDay, \"start\"=@Start, " +
                         "\"end\"=@End, \"location\"=@Location, \"description\"=@Description, " +
                         "\"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                         "WHERE \"id\"=@Id", dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
Beispiel #10
0
        public static Common.Models.Events.Event Create(Common.Models.Events.Event 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.Events.Event dbo = null;

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

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("INSERT INTO \"event\" (\"id\", \"title\", \"allday\", \"start\", \"end\", \"location\", \"description\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Id, @Title, @AllDay, @Start, @End, @Location, @Description, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo);
            }

            return(model);
        }
        public static Common.Models.Events.EventTask RelateToTask(Common.Models.Events.Event model,
                                                                  Common.Models.Tasks.Task task,
                                                                  Common.Models.Account.Users actor,
                                                                  IDbConnection conn = null, bool closeConnection = true)
        {
            Common.Models.Events.EventTask et;
            DBOs.Events.EventTask          dbo = null;

            et = Data.Events.EventTask.Get(task.Id.Value, model.Id.Value);

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

            et           = new Common.Models.Events.EventTask();
            et.Id        = Guid.NewGuid();
            et.CreatedBy = et.ModifiedBy = actor;
            et.Created   = et.Modified = DateTime.UtcNow;
            et.Event     = model;
            et.Task      = task;

            dbo = Mapper.Map <DBOs.Events.EventTask>(et);

            conn = DataHelper.OpenIfNeeded(conn);

            if (conn.Execute("INSERT INTO \"event_task\" (\"id\", \"event_id\", \"task_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Id, @EventId, @TaskId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo) > 0)
            {
                model.Id = conn.Query <DBOs.Events.EventTask>("SELECT currval(pg_get_serial_sequence('event_task', 'id')) AS \"id\"").Single().Id;
            }

            DataHelper.Close(conn, closeConnection);

            return(et);
        }
        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.Events.Event Create(Common.Models.Events.Event 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.Events.Event dbo = null;

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

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("INSERT INTO \"event\" (\"id\", \"title\", \"allday\", \"start\", \"end\", \"location\", \"description\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                         "VALUES (@Id, @Title, @AllDay, @Start, @End, @Location, @Description, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                         dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }