Esempio n. 1
0
        public static Common.Models.Timing.TimeCategory Edit(
            Common.Models.Timing.TimeCategory model,
            Common.Models.Account.Users modifier,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Timing.TimeCategory dbo = Mapper.Map <DBOs.Timing.TimeCategory>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("UPDATE \"time_category\" SET " +
                         "\"title\"=@Title, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                         "WHERE \"id\"=@Id", dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
Esempio n. 2
0
        public static Common.Models.Timing.TimeCategory Create(
            Common.Models.Timing.TimeCategory model,
            Common.Models.Account.Users creator,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.CreatedBy = model.ModifiedBy = creator;
            model.Created   = model.Modified = DateTime.UtcNow;
            DBOs.Timing.TimeCategory dbo = Mapper.Map <DBOs.Timing.TimeCategory>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            if (conn.Execute("INSERT INTO \"time_category\" (\"title\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Title, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo) > 0)
            {
                model.Id = conn.Query <DBOs.Timing.TimeCategory>("SELECT currval(pg_get_serial_sequence('time_category', 'id')) AS \"id\"").Single().Id;
            }

            DataHelper.Close(conn, closeConnection);

            return(model);
        }